Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tagbuildr-node

buzzin06094MIT0.0.2

Standalone component and templating utility for Node JS

templating, components, node, templates, node, components, html-templates, html-tags

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()
    ])
  );
});