Skip to content

Instantly share code, notes, and snippets.

@johannilsson
Last active December 27, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johannilsson/7399328 to your computer and use it in GitHub Desktop.
Save johannilsson/7399328 to your computer and use it in GitHub Desktop.
Templating with Browserify, domify & brfs.
browserify index.js -o bundle.js -t brfs
var domify = require('domify');
var fs = require('fs');
var template = domify(fs.readFileSync(__dirname + '/template.html'));
var row = domify(fs.readFileSync(__dirname + '/row.html'));
var content = template.querySelector('#content');
[1,2,3,4,5,7,8,9].forEach(function(data) {
row.innerHTML = data;
content.appendChild(row.cloneNode(true));
});
document.body.appendChild(template);
{
"name": "brfsdomify",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-2-Clause",
"dependencies": {
"brfs": "0.0.8",
"domify": "~1.0.0"
}
}
<!-- Created DOM -->
<div>
<h1>My Fancy Site</h1>
<div id="content"><p>1</p><p>2</p><p>3</p><p>4</p><p>5</p><p>7</p><p>8</p><p>9</p></div>
</div>
<p>Some content</p>
<div>
<h1>My Fancy Site</h1>
<div id="content"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment