tagbuildr-node
v0.0.2
Published
Standalone component and templating utility for Node JS
Downloads
2
Maintainers
Readme
tagbuildr-node
Library agnostic component and templating utility for Node JS
Based off the browser version - tagbuildr - see that repository for more examples
Library and framework agnostic
You do not need to do anything to integrate tagbuildr node with your app. Here's an example with Express:
const tb = require('tagbuildr-node');
app.get('/some-api-request', function(req, res) {
res.send(tb('h1.awesome-title', 'Awesome Title'));
});
This will send back:
<h1 class="awesome-title">Awesome Title</h1>
Component focussed
tagbuildr-node is best used for component based tasks e.g. sending back a list of article elements in an api call.
However, it could be used as a full templating solution. Here is a rough example in Express js style again:
function Document(children) {
return tb('html', children);
}
function Head() {
return [
tb('script|src=my-script-url.js'),
tb('link|rel=stylesheet|type=text/css|href=my-css-url.css')
]
}
function Body() {
return tb('body', [
tb('h1.site-title', 'Hello, World!')
]);
}
app.get('/', function(req, res) {
res.send(
Document([
Head(),
Body()
])
);
});