div.contianer
ul.images
li
img(src=imageSource)
function template(locals) {
var buf = [];
var jade_mixins = {};
var locals_ = locals || {}, imageSource = locals_.imageSource;
buf.push('<div class="contianer"><ul class="images"><li><img' + jade.attr("src", imageSource, true, false) + "/></li></ul></div>");
return buf.join("");
}
var template = require('./example.jade');
var template = function template(locals) {
var buf = [];
var jade_mixins = {};
var locals_ = locals || {}, imageSource = locals_.imageSource;
buf.push('<div class="contianer"><ul class="images"><li><img' + jade.attr("src", imageSource, true, false) + "/></li></ul></div>");
return buf.join("");
}
<span>{{ helpers.date.relative(myDate) }}</span>
require('./example.jade');
// what you really want for en-US user
require('./example_en-US.jade'); // fall back to example.jade if it doesn't exist
var tempreg = require('tempreg');
tempreg.register('example.jade', fn); // register a template fn
tempreg.get(example.jade'); // get a handle to the render fn
tempreg('example.jade', data); // render it
// mixin common view helpers in one place, even use common npm modules
helpers = { date: require('moment') };
tempreg.on('pre-render', function(data) {
data.helpers = helpers;
});
// create scoped instance
var myTempreg = tempreg.create();
myTempreg.on('pre-render', fn);
// vanilla template transform
var template = function template(locals) {...};
// register template with tempreg in transform
var template = require('tempreg')
.register('example.jade', function template(locals) {...})
.get('example.jade');
template(data); // renders template via registry, calling all pre-render hooks
// usually we don't use the return result of the require, we just want it registered for any templates that will be rendered
require('./index.pres');
var inserted = [];
module.exports = function (css) {
if (inserted.indexOf(css) >= 0) return;
inserted.push(css);
var elem = document.createElement('style');
var text = document.createTextNode(css);
elem.appendChild(text);
document.head.appendChild(elem);
};
// these styles are automatically bundled into this javascript file
require('./index.less');
// they have now been appended to the document in a style tag