Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

templatizer

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templatizer - npm Package Compare versions

Comparing version 0.2.10 to 0.3.0

templates/underscoreUsers.jade

12

benchmark/build-demo.js

@@ -1,7 +0,9 @@

var templatizer = require('../templatizer'),
path = require('path');
var templatizer = require('../templatizer');
var path = require('path');
var tmplPath = path.resolve(__dirname, '../templates');
var tmplPath2 = path.resolve(__dirname, '../templates2');
templatizer(path.resolve(__dirname, '../templates'), path.resolve(__dirname, '../test/demo_output_no_mixins.js'), true);
templatizer([path.resolve(__dirname, '../templates'), path.resolve(__dirname, '../templates2')], path.resolve(__dirname, '../test/demo_output_multiple_dirs.js'));
templatizer(path.resolve(__dirname, '../templates'), path.resolve(__dirname, '../demo_output.js'));
templatizer(tmplPath, path.resolve(__dirname, '../test/demo_output_no_mixins.js'), {dontTransformMixins: true});
templatizer([tmplPath, tmplPath2], path.resolve(__dirname, '../test/demo_output_multiple_dirs.js'));
templatizer(tmplPath, path.resolve(__dirname, '../demo_output.js'));

@@ -0,1 +1,211 @@

!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jade=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
/**
* Merge two attribute objects giving precedence
* to values in object `b`. Classes are special-cased
* allowing for arrays and merging/joining appropriately
* resulting in a string.
*
* @param {Object} a
* @param {Object} b
* @return {Object} a
* @api private
*/
exports.merge = function merge(a, b) {
if (arguments.length === 1) {
var attrs = a[0];
for (var i = 1; i < a.length; i++) {
attrs = merge(attrs, a[i]);
}
return attrs;
}
var ac = a['class'];
var bc = b['class'];
if (ac || bc) {
ac = ac || [];
bc = bc || [];
if (!Array.isArray(ac)) ac = [ac];
if (!Array.isArray(bc)) bc = [bc];
a['class'] = ac.concat(bc).filter(nulls);
}
for (var key in b) {
if (key != 'class') {
a[key] = b[key];
}
}
return a;
};
/**
* Filter null `val`s.
*
* @param {*} val
* @return {Boolean}
* @api private
*/
function nulls(val) {
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
*/
exports.joinClasses = joinClasses;
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given classes.
*
* @param {Array} classes
* @param {Array.<Boolean>} escaped
* @return {String}
*/
exports.cls = function cls(classes, escaped) {
var buf = [];
for (var i = 0; i < classes.length; i++) {
if (escaped && escaped[i]) {
buf.push(exports.escape(joinClasses([classes[i]])));
} else {
buf.push(joinClasses(classes[i]));
}
}
var text = joinClasses(buf);
if (text.length) {
return ' class="' + text + '"';
} else {
return '';
}
};
/**
* Render the given attribute.
*
* @param {String} key
* @param {String} val
* @param {Boolean} escaped
* @param {Boolean} terse
* @return {String}
*/
exports.attr = function attr(key, val, escaped, terse) {
if ('boolean' == typeof val || null == val) {
if (val) {
return ' ' + (terse ? key : key + '="' + key + '"');
} else {
return '';
}
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
} else if (escaped) {
return ' ' + key + '="' + exports.escape(val) + '"';
} else {
return ' ' + key + '="' + val + '"';
}
};
/**
* Render the given attributes object.
*
* @param {Object} obj
* @param {Object} escaped
* @return {String}
*/
exports.attrs = function attrs(obj, terse){
var buf = [];
var keys = Object.keys(obj);
if (keys.length) {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i]
, val = obj[key];
if ('class' == key) {
if (val = joinClasses(val)) {
buf.push(' ' + key + '="' + val + '"');
}
} else {
buf.push(exports.attr(key, val, false, terse));
}
}
}
return buf.join('');
};
/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/
exports.escape = function escape(html){
var result = String(html)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
if (result === '' + html) return html;
else return result;
};
/**
* Re-throw the given `err` in context to the
* the jade in `filename` at the given `lineno`.
*
* @param {Error} err
* @param {String} filename
* @param {String} lineno
* @api private
*/
exports.rethrow = function rethrow(err, filename, lineno, str){
if (!(err instanceof Error)) throw err;
if ((typeof window != 'undefined' || !filename) && !str) {
err.message += ' on line ' + lineno;
throw err;
}
try {
str = str || _dereq_('fs').readFileSync(filename, 'utf8')
} catch (ex) {
rethrow(err, null, lineno)
}
var context = 3
, lines = str.split('\n')
, start = Math.max(lineno - context, 0)
, end = Math.min(lines.length, lineno + context);
// Error context
var context = lines.slice(start, end).map(function(line, i){
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ')
+ curr
+ '| '
+ line;
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'Jade') + ':' + lineno
+ '\n' + context + '\n\n' + err.message;
throw err;
};
},{"fs":2}],2:[function(_dereq_,module,exports){
},{}]},{},[1])
(1)
});
(function () {

@@ -5,5 +215,3 @@ var root = this, exports = {};

// The jade runtime:
var jade = exports.jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(key);return arr}),exports.merge=function merge(a,b){var ac=a["class"],bc=b["class"];if(ac||bc)ac=ac||[],bc=bc||[],Array.isArray(ac)||(ac=[ac]),Array.isArray(bc)||(bc=[bc]),ac=ac.filter(nulls),bc=bc.filter(nulls),a["class"]=ac.concat(bc).join(" ");for(var key in b)key!="class"&&(a[key]=b[key]);return a};function nulls(val){return val!=null}return exports.attrs=function attrs(obj,escaped){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):0==key.indexOf("data")&&"string"!=typeof val?buf.push(key+"='"+JSON.stringify(val)+"'"):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):escaped&&escaped[key]?buf.push(key+'="'+exports.escape(val)+'"'):buf.push(key+'="'+val+'"')}}return buf.join(" ")},exports.escape=function escape(html){return String(html).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function rethrow(err,filename,lineno){if(!filename)throw err;var context=3,str=require("fs").readFileSync(filename,"utf8"),lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message,err},exports}({});
// create our folder objects

@@ -22,4 +230,8 @@ exports["otherfolder"] = {};

var buf = [];
var locals_ = locals || {}, content = locals_.content;
buf.push('<div class="page-404">' + jade.escape((jade.interp = content || '404') == null ? '' : jade.interp) + '!</div>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (content) {
buf.push('<div class="page-404">' + jade.escape((jade_interp = content || '404') == null ? '' : jade_interp) + '!</div>');
}('content' in locals_for_with ? locals_for_with.content : typeof content !== 'undefined' ? content : undefined));
return buf.join('');

@@ -31,4 +243,8 @@ };

var buf = [];
var locals_ = locals || {}, tweet = locals_.tweet;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = tweet) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (tweet) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = tweet) ? '' : jade_interp) + '</li>');
}('tweet' in locals_for_with ? locals_for_with.tweet : typeof tweet !== 'undefined' ? tweet : undefined));
return buf.join('');

@@ -40,4 +256,8 @@ };

var buf = [];
var locals_ = locals || {}, tweet = locals_.tweet;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = tweet) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (tweet) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = tweet) ? '' : jade_interp) + '</li>');
}('tweet' in locals_for_with ? locals_for_with.tweet : typeof tweet !== 'undefined' ? tweet : undefined));
return buf.join('');

@@ -49,37 +269,35 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');
};
// otherfolder/nestedMixin.jade:user_li_mixin compiled template
exports["otherfolder"]["nestedMixin"]["user_li"] = function tmpl_otherfolder_nestedMixin_user_li_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<li" + jade.attrs({
"data-user-id": user.id,
"data-user-index": index
}, {
"data-user-id": true,
"data-user-index": true
}) + ">test</li>");
// otherfolder/nestedMixin.jade:user_li compiled template
exports["otherfolder"]["nestedMixin"]["user_li"] = function tmpl_otherfolder_nestedMixin_user_li(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<li" + jade.attr("data-user-id", user.id, true, false) + jade.attr("data-user-index", index, true, false) + ">test</li>");
return buf.join("");

@@ -91,29 +309,66 @@ };

var buf = [];
var locals_ = locals || {}, user = locals_.user;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (user) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = user) ? '' : jade_interp) + '</li>');
}('user' in locals_for_with ? locals_for_with.user : typeof user !== 'undefined' ? user : undefined));
return buf.join('');
};
// underscoreUsers.jade compiled template
exports["underscoreUsers"] = function tmpl_underscoreUsers(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users, _) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape((jade_interp = _.isObject(user) && _.isString(user.name) ? user.name : '') == null ? '' : jade_interp) + '</li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape((jade_interp = _.isObject(user) && _.isString(user.name) ? user.name : '') == null ? '' : jade_interp) + '</li>');
}
}
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined, '_' in locals_for_with ? locals_for_with._ : typeof _ !== 'undefined' ? _ : undefined));
return buf.join('');
};
// users.jade compiled template
exports["users"] = function tmpl_users(locals) {
var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade_interp = user.name) ? '' : jade_interp) + '</li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade_interp = user.name) ? '' : jade_interp) + '</li>');
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');

@@ -125,37 +380,35 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');
};
// usersMixins.jade:user_li_mixin compiled template
exports["usersMixins"]["user_li"] = function tmpl_usersMixins_user_li_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<li" + jade.attrs({
"data-user-id": user.id,
"data-user-index": index
}, {
"data-user-id": true,
"data-user-index": true
}) + "><span>Before</span>");
// usersMixins.jade:user_li compiled template
exports["usersMixins"]["user_li"] = function tmpl_usersMixins_user_li(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<li" + jade.attr("data-user-id", user.id, true, false) + jade.attr("data-user-index", index, true, false) + "><span>Before</span>");
buf.push(exports.usersMixins.user_a(user, index));

@@ -166,12 +419,6 @@ buf.push("</li>");

// usersMixins.jade:user_a_mixin compiled template
exports["usersMixins"]["user_a"] = function tmpl_usersMixins_user_a_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<a" + jade.attrs({
href: user.url,
"data-user-index": index
}, {
href: true,
"data-user-index": true
}) + ">Within " + jade.escape((jade.interp = user.name) == null ? "" : jade.interp) + "</a>");
// usersMixins.jade:user_a compiled template
exports["usersMixins"]["user_a"] = function tmpl_usersMixins_user_a(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<a" + jade.attr("href", user.url, true, false) + jade.attr("data-user-index", index, true, false) + ">Within " + jade.escape((jade_interp = user.name) == null ? "" : jade_interp) + "</a>");
return buf.join("");

@@ -183,21 +430,25 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li' + jade.attrs({ 'data-user-id': user.id }, { 'data-user-id': true }) + '><span>Before</span><a' + jade.attrs({ href: user.url }, { href: true }) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a></li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + '><span>Before</span><a' + jade.attr('href', user.url, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a></li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + '><span>Before</span><a' + jade.attr('href', user.url, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a></li>');
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li' + jade.attrs({ 'data-user-id': user.id }, { 'data-user-id': true }) + '><span>Before</span><a' + jade.attrs({ href: user.url }, { href: true }) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a></li>');
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');

@@ -204,0 +455,0 @@ };

@@ -1,1 +0,210 @@

jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(key);return arr}),exports.merge=function merge(a,b){var ac=a["class"],bc=b["class"];if(ac||bc)ac=ac||[],bc=bc||[],Array.isArray(ac)||(ac=[ac]),Array.isArray(bc)||(bc=[bc]),ac=ac.filter(nulls),bc=bc.filter(nulls),a["class"]=ac.concat(bc).join(" ");for(var key in b)key!="class"&&(a[key]=b[key]);return a};function nulls(val){return val!=null}return exports.attrs=function attrs(obj,escaped){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):0==key.indexOf("data")&&"string"!=typeof val?buf.push(key+"='"+JSON.stringify(val)+"'"):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):escaped&&escaped[key]?buf.push(key+'="'+exports.escape(val)+'"'):buf.push(key+'="'+val+'"')}}return buf.join(" ")},exports.escape=function escape(html){return String(html).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function rethrow(err,filename,lineno){if(!filename)throw err;var context=3,str=require("fs").readFileSync(filename,"utf8"),lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message,err},exports}({});
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jade=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
/**
* Merge two attribute objects giving precedence
* to values in object `b`. Classes are special-cased
* allowing for arrays and merging/joining appropriately
* resulting in a string.
*
* @param {Object} a
* @param {Object} b
* @return {Object} a
* @api private
*/
exports.merge = function merge(a, b) {
if (arguments.length === 1) {
var attrs = a[0];
for (var i = 1; i < a.length; i++) {
attrs = merge(attrs, a[i]);
}
return attrs;
}
var ac = a['class'];
var bc = b['class'];
if (ac || bc) {
ac = ac || [];
bc = bc || [];
if (!Array.isArray(ac)) ac = [ac];
if (!Array.isArray(bc)) bc = [bc];
a['class'] = ac.concat(bc).filter(nulls);
}
for (var key in b) {
if (key != 'class') {
a[key] = b[key];
}
}
return a;
};
/**
* Filter null `val`s.
*
* @param {*} val
* @return {Boolean}
* @api private
*/
function nulls(val) {
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
*/
exports.joinClasses = joinClasses;
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given classes.
*
* @param {Array} classes
* @param {Array.<Boolean>} escaped
* @return {String}
*/
exports.cls = function cls(classes, escaped) {
var buf = [];
for (var i = 0; i < classes.length; i++) {
if (escaped && escaped[i]) {
buf.push(exports.escape(joinClasses([classes[i]])));
} else {
buf.push(joinClasses(classes[i]));
}
}
var text = joinClasses(buf);
if (text.length) {
return ' class="' + text + '"';
} else {
return '';
}
};
/**
* Render the given attribute.
*
* @param {String} key
* @param {String} val
* @param {Boolean} escaped
* @param {Boolean} terse
* @return {String}
*/
exports.attr = function attr(key, val, escaped, terse) {
if ('boolean' == typeof val || null == val) {
if (val) {
return ' ' + (terse ? key : key + '="' + key + '"');
} else {
return '';
}
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
} else if (escaped) {
return ' ' + key + '="' + exports.escape(val) + '"';
} else {
return ' ' + key + '="' + val + '"';
}
};
/**
* Render the given attributes object.
*
* @param {Object} obj
* @param {Object} escaped
* @return {String}
*/
exports.attrs = function attrs(obj, terse){
var buf = [];
var keys = Object.keys(obj);
if (keys.length) {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i]
, val = obj[key];
if ('class' == key) {
if (val = joinClasses(val)) {
buf.push(' ' + key + '="' + val + '"');
}
} else {
buf.push(exports.attr(key, val, false, terse));
}
}
}
return buf.join('');
};
/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/
exports.escape = function escape(html){
var result = String(html)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
if (result === '' + html) return html;
else return result;
};
/**
* Re-throw the given `err` in context to the
* the jade in `filename` at the given `lineno`.
*
* @param {Error} err
* @param {String} filename
* @param {String} lineno
* @api private
*/
exports.rethrow = function rethrow(err, filename, lineno, str){
if (!(err instanceof Error)) throw err;
if ((typeof window != 'undefined' || !filename) && !str) {
err.message += ' on line ' + lineno;
throw err;
}
try {
str = str || require('fs').readFileSync(filename, 'utf8')
} catch (ex) {
rethrow(err, null, lineno)
}
var context = 3
, lines = str.split('\n')
, start = Math.max(lineno - context, 0)
, end = Math.min(lines.length, lineno + context);
// Error context
var context = lines.slice(start, end).map(function(line, i){
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ')
+ curr
+ '| '
+ line;
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'Jade') + ':' + lineno
+ '\n' + context + '\n\n' + err.message;
throw err;
};
},{"fs":2}],2:[function(require,module,exports){
},{}]},{},[1])
(1)
});

@@ -6,14 +6,2 @@ var esprima = require('esprima');

// RegEx that identifies the name of a jade mixin fn
var rIsMixin = /_mixin$/;
// Determine if an expression from an AST
// is a call to a jade mixin
var isMixinCall = function (expression) {
var sExprType = expression && expression.type,
sCallee = expression && expression.callee,
sCalleeName = sCallee && sCallee.name;
return sExprType === 'CallExpression' && rIsMixin.test(sCalleeName);
};
// Traverse an AST with access to the node and

@@ -43,3 +31,6 @@ // the parent node during traversal

traverse(tree, function (node, parent) {
if (node.type === 'CallExpression' && node.callee && rIsMixin.test(node.callee.name)) {
if (node.type === 'CallExpression' && node.callee &&
node.callee.type === 'MemberExpression' &&
node.callee.object.name === 'jade_mixins') {
// transform the call to the mixin fn and namespace it on this[ns]

@@ -55,53 +46,49 @@ parent = transformMixinCall(parent, ns);

var transformMixinCall = function (statement, ns) {
// Property name of 'jade_mixins' is our mixin name
var newName = statement.expression.callee.property.value;
var oldArgs = statement.expression.arguments;
var newCallee;
if (isMixinCall(statement.expression)) {
// Make the mixin call as an argument to buf.push
statement.expression.callee = {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'buf'
},
property: {
type: 'Identifier',
name: 'push'
}
};
var oldName = statement.expression.callee.name;
var oldArgs = statement.expression.arguments;
var newName = oldName.replace(rIsMixin, '');
var newCallee;
// Add our altered mixin name to our ns array
ns = ns.split('.').concat(newName);
// Make the mixin call as an argument to buf.push
statement.expression.callee = {
// Loop through and build the namespaced callee
for (var i = 1, l = ns.length; i < l; i++) {
newCallee = JSON.stringify({
type: 'MemberExpression',
computed: false,
object: {
object: i === 1 ? {
type: 'Identifier',
name: 'buf'
},
name: ns[i - 1]
} : JSON.parse(newCallee),
property: {
type: 'Identifier',
name: 'push'
name: ns[i]
}
};
});
}
// Add our altered mixin name to our ns array
ns = ns.split('.').concat(newName);
// Loop through and build the namespaced callee
for (var i = 1, l = ns.length; i < l; i++) {
newCallee = JSON.stringify({
type: 'MemberExpression',
computed: false,
object: i === 1 ? {
type: 'Identifier',
name: ns[i - 1]
} : JSON.parse(newCallee),
property: {
type: 'Identifier',
name: ns[i]
}
});
// Add namespaced callee as the argument
statement.expression.arguments = [
{
type: 'CallExpression',
callee: JSON.parse(newCallee),
arguments: oldArgs
}
];
// Add namespaced callee as the argument
statement.expression.arguments = [
{
type: 'CallExpression',
callee: JSON.parse(newCallee),
arguments: oldArgs
}
];
}
return statement;

@@ -121,28 +108,47 @@ };

var funcRoot = ast.body[0].body.body;
if (funcRoot.length === 3) {
if (funcRoot.length === 5) {
//determine if there are only the buf declaration, the push of one string and then the return of the buf.join
var simple = false;
var simpleString = '';
var cnt = 0;
try {
/* check for buf declare */
if (funcRoot[0].type === "VariableDeclaration" && funcRoot[0].declarations[0].id.name === "buf" &&
(funcRoot[0].declarations[0].init.elements instanceof Array && funcRoot[0].declarations[0].init.elements.length === 0)) {
funcRoot.forEach(function (node, i) {
/* check for buf declare */
if (i === 0 && node.type === "VariableDeclaration" && node.declarations[0].id.name === "buf" &&
(node.declarations[0].init.elements instanceof Array && node.declarations[0].init.elements.length === 0)) {
cnt++;
}
/* check for jade_mixins declare */
if (i === 1 && node.type === "VariableDeclaration" && node.declarations[0].id.name === "jade_mixins" &&
(node.declarations[0].init.type === 'ObjectExpression' && node.declarations[0].init.properties.length === 0)) {
cnt++;
}
/* check for jade_interp declare */
if (i === 2 && node.type === "VariableDeclaration" && node.declarations[0].id.name === "jade_interp" &&
(node.declarations[0].init === null)) {
cnt++;
}
/* check for single string push */
if (funcRoot[1].type === "ExpressionStatement" && funcRoot[1].expression.callee.object.name === "buf" &&
funcRoot[1].expression.arguments.length === 1 && funcRoot[1].expression.arguments[0].type === "Literal") {
if (i === 3 && node.type === "ExpressionStatement" && node.expression.callee.object.name === "buf" &&
node.expression.arguments.length === 1 && node.expression.arguments[0].type === "Literal") {
/* save the simple string */
simpleString = funcRoot[1].expression.arguments[0].value;
/* check for buf join */
if (funcRoot[2].type === "ReturnStatement" && funcRoot[2].argument.callee.object.name === "buf" &&
funcRoot[2].argument.callee.property.name === "join" && funcRoot[2].argument.arguments.length === 1 && funcRoot[2].argument.arguments[0].value === '') {
simple = true;
}
simpleString = node.expression.arguments[0].value;
cnt++;
}
}
}
catch (e) {
simple = false;
}
if (simple) {
/* check for buf join */
if (i === 4 && node.type === "ReturnStatement" && node.argument.callee.object.name === "buf" &&
node.argument.callee.property.name === "join" && node.argument.arguments.length === 1 && node.argument.arguments[0].value === '') {
cnt++;
}
});
} catch (e) {}
// All the conditions were met, it's a simple template
if (cnt === 5) {
//replace the funcRoot with a simple return;

@@ -163,3 +169,3 @@ var simpleRoot = [{

return escodegen.generate(ast);
}
};

@@ -173,3 +179,2 @@ module.exports.getMixins = function (options) {

var mixinOutput = '';
var removeDeclarations = [];
var outputTemplate = options.template;

@@ -186,77 +191,105 @@

if (type === 'VariableDeclaration' && rIsMixin.test(declarationName)) {
// It's a mixin so we'll make our changes and mark the index for removal
removeDeclarations.push(treeI);
// Get mixin function from variable declaration
fnTree = cloneTree.declarations[0].init;
var removeDeclarations = [];
if (type === 'ExpressionStatement' &&
cloneTree.expression.type === 'CallExpression' &&
cloneTree.expression.callee.type === 'FunctionExpression') {
cloneTree.expression.callee.body.body.forEach(function (expr, exprI) {
var mixinName;
if (expr.type === 'ExpressionStatement' &&
expr.expression.type === 'AssignmentExpression' &&
expr.expression.left.object.name === 'jade_mixins') {
removeDeclarations.push(exprI);
mixinName = expr.expression.left.property.value;
// Change to an anonymous function to be assigned later
fnTree.type = 'FunctionDeclaration';
fnTree.id = {
type: 'Identifier',
name: 'tmpl_' + dirString.replace(/[^A-Za-z0-9]/g, '_') + '_' + declarationName
};
statements = fnTree.body.body;
// Get mixin function from variable declaration
fnTree = expr.expression.right;
// Replace calls to other mixins within the file
transformAllMixins(statements, parentObjName + '.' + dirString);
// Change to an anonymous function to be assigned later
fnTree.type = 'FunctionDeclaration';
fnTree.id = {
type: 'Identifier',
name: 'tmpl_' + dirString.replace(/[^A-Za-z0-9]/g, '_') + '_' + mixinName
};
statements = fnTree.body.body;
// Add a variable declaration for the buf array
// since that was previously handled by jade
statements[0].declarations.push({
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'buf'
},
init: {
type: 'ArrayExpression',
elements: []
}
});
// return the buf array
statements.push({
type: 'ReturnStatement',
argument: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
// Replace calls to other mixins within the file
transformAllMixins(statements, parentObjName + '.' + dirString);
// Add a variable declaration for the buf array
// since that was previously handled by jade
statements[0].declarations.push({
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'buf'
},
property: {
init: {
type: 'ArrayExpression',
elements: []
},
},
{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'join'
name: 'jade_interp'
},
init: null
});
// return the buf array
statements.push({
type: 'ReturnStatement',
argument: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'buf'
},
property: {
type: 'Identifier',
name: 'join'
}
},
arguments: [
{
type: 'Literal',
value: '',
raw: '""'
}
]
}
},
arguments: [
{
type: 'Literal',
value: '',
raw: '""'
}
]
});
// Generate fn and store until it can be added to output after main fn
generatedMixinFn = beautify(escodegen.generate(fnTree));
mixinOutput += [
'',
'// ' + dirString.replace(/\./g, '/') + '.jade:' + mixinName + ' compiled template',
'' + parentObjName + '["' + dirString.replace(/\./g, '"]["') + '"]["' + mixinName.replace(/\./g, '"]["') + '"] = ' + generatedMixinFn + ';',
''
].join('\n');
}
});
}
// Generate fn and store until it can be added to output after main fn
generatedMixinFn = beautify(escodegen.generate(fnTree));
mixinOutput += [
'',
'// ' + dirString.replace(/\./g, '/') + '.jade:' + declarationName + ' compiled template',
'' + parentObjName + '["' + dirString.replace(/\./g, '"]["') + '"]["' + declarationName.replace(rIsMixin, '').replace(/\./g, '"]["') + '"] = ' + generatedMixinFn + ';',
''
].join('\n');
if (removeDeclarations.length) {
// Remove mixin declarations
var len = removeDeclarations.length;
while (len--) {
tree.expression.callee.body.body.splice(removeDeclarations[len], 1);
}
removeDeclarations = [];
}
});
if (removeDeclarations.length) {
// Remove mixin declarations
var len = removeDeclarations.length;
while (len--) {
astBody.splice(removeDeclarations[len], 1);
}
// We actually found mixins
if (mixinOutput) {
// Traverse and replace mixin calls with buf.push(exports[dirString][mixin]())

@@ -263,0 +296,0 @@ transformAllMixins(ast, parentObjName + '.' + dirString);

{
"name": "templatizer",
"version": "0.2.10",
"version": "0.3.0",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -17,3 +17,3 @@ "contributors": [

"dependencies": {
"jade": "0.35.0",
"jade": "^1.3.0",
"uglify-js": "2.4.0",

@@ -20,0 +20,0 @@ "walkdir": "0.0.7",

@@ -25,3 +25,3 @@ # templatizer.js

// save the output file as. That's it!
templatizer(__dirname + '/templates', __dirname + '/demo_output.js');
templatizer(__dirname + '/templates', __dirname + '/demo_output.js', options);
```

@@ -62,2 +62,6 @@

### Jade Options
Use `options.jade` to set options for when templatizer calls `jade.compile(file, options.jade)`.
### Mixin Support

@@ -64,0 +68,0 @@

@@ -10,3 +10,10 @@ var jade = require('jade');

module.exports = function (templateDirectories, outputFile, dontTransformMixins) {
module.exports = function (templateDirectories, outputFile, options) {
options || (options = {});
_.defaults(options, {
dontTransformMixins: false,
jade: {}
});
if (typeof templateDirectories === "string") {

@@ -23,4 +30,3 @@ templateDirectories = [templateDirectories];

var placesToLook = [
__dirname + '/../jade/runtime.min.js',
__dirname + '/node_modules/jade/runtime.min.js',
__dirname + '/node_modules/jade/runtime.js',
__dirname + '/jaderuntime.min.js'

@@ -31,2 +37,3 @@ ];

var output = [
jadeRuntime,
'(function () {',

@@ -36,6 +43,12 @@ 'var root = this, ' + parentObjName + ' = {};',

'// The jade runtime:',
'var jade = ' + parentObjName + '.' + jadeRuntime,
''
].join('\n');
var jadeCompileOptions = {
client: true,
compileDebug: false,
pretty: false
};
_.extend(jadeCompileOptions, options.jade);
templateDirectories = _.map(templateDirectories, function (templateDirectory) {

@@ -87,9 +100,6 @@ return templateDirectory.replace(pathSepRegExp, pathSep);

var mixinOutput = '';
var template = beautify(jade.compile(fs.readFileSync(item, 'utf-8'), {
client: true,
compileDebug: false,
pretty: false,
filename: item
}).toString());
jadeCompileOptions.filename = item;
var template = beautify(jade.compileClient(fs.readFileSync(item, 'utf-8'), jadeCompileOptions).toString());
template = jadeAst.renameFunc(template, dirString);

@@ -105,3 +115,3 @@

mixinOutput = astResult.mixins;
if (!dontTransformMixins) template = astResult.template;
if (!options.dontTransformMixins) template = astResult.template;

@@ -108,0 +118,0 @@ template = jadeAst.simplifyTemplate(template);

@@ -0,1 +1,211 @@

!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jade=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
/**
* Merge two attribute objects giving precedence
* to values in object `b`. Classes are special-cased
* allowing for arrays and merging/joining appropriately
* resulting in a string.
*
* @param {Object} a
* @param {Object} b
* @return {Object} a
* @api private
*/
exports.merge = function merge(a, b) {
if (arguments.length === 1) {
var attrs = a[0];
for (var i = 1; i < a.length; i++) {
attrs = merge(attrs, a[i]);
}
return attrs;
}
var ac = a['class'];
var bc = b['class'];
if (ac || bc) {
ac = ac || [];
bc = bc || [];
if (!Array.isArray(ac)) ac = [ac];
if (!Array.isArray(bc)) bc = [bc];
a['class'] = ac.concat(bc).filter(nulls);
}
for (var key in b) {
if (key != 'class') {
a[key] = b[key];
}
}
return a;
};
/**
* Filter null `val`s.
*
* @param {*} val
* @return {Boolean}
* @api private
*/
function nulls(val) {
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
*/
exports.joinClasses = joinClasses;
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given classes.
*
* @param {Array} classes
* @param {Array.<Boolean>} escaped
* @return {String}
*/
exports.cls = function cls(classes, escaped) {
var buf = [];
for (var i = 0; i < classes.length; i++) {
if (escaped && escaped[i]) {
buf.push(exports.escape(joinClasses([classes[i]])));
} else {
buf.push(joinClasses(classes[i]));
}
}
var text = joinClasses(buf);
if (text.length) {
return ' class="' + text + '"';
} else {
return '';
}
};
/**
* Render the given attribute.
*
* @param {String} key
* @param {String} val
* @param {Boolean} escaped
* @param {Boolean} terse
* @return {String}
*/
exports.attr = function attr(key, val, escaped, terse) {
if ('boolean' == typeof val || null == val) {
if (val) {
return ' ' + (terse ? key : key + '="' + key + '"');
} else {
return '';
}
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
} else if (escaped) {
return ' ' + key + '="' + exports.escape(val) + '"';
} else {
return ' ' + key + '="' + val + '"';
}
};
/**
* Render the given attributes object.
*
* @param {Object} obj
* @param {Object} escaped
* @return {String}
*/
exports.attrs = function attrs(obj, terse){
var buf = [];
var keys = Object.keys(obj);
if (keys.length) {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i]
, val = obj[key];
if ('class' == key) {
if (val = joinClasses(val)) {
buf.push(' ' + key + '="' + val + '"');
}
} else {
buf.push(exports.attr(key, val, false, terse));
}
}
}
return buf.join('');
};
/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/
exports.escape = function escape(html){
var result = String(html)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
if (result === '' + html) return html;
else return result;
};
/**
* Re-throw the given `err` in context to the
* the jade in `filename` at the given `lineno`.
*
* @param {Error} err
* @param {String} filename
* @param {String} lineno
* @api private
*/
exports.rethrow = function rethrow(err, filename, lineno, str){
if (!(err instanceof Error)) throw err;
if ((typeof window != 'undefined' || !filename) && !str) {
err.message += ' on line ' + lineno;
throw err;
}
try {
str = str || _dereq_('fs').readFileSync(filename, 'utf8')
} catch (ex) {
rethrow(err, null, lineno)
}
var context = 3
, lines = str.split('\n')
, start = Math.max(lineno - context, 0)
, end = Math.min(lines.length, lineno + context);
// Error context
var context = lines.slice(start, end).map(function(line, i){
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ')
+ curr
+ '| '
+ line;
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'Jade') + ':' + lineno
+ '\n' + context + '\n\n' + err.message;
throw err;
};
},{"fs":2}],2:[function(_dereq_,module,exports){
},{}]},{},[1])
(1)
});
(function () {

@@ -5,5 +215,3 @@ var root = this, exports = {};

// The jade runtime:
var jade = exports.jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(key);return arr}),exports.merge=function merge(a,b){var ac=a["class"],bc=b["class"];if(ac||bc)ac=ac||[],bc=bc||[],Array.isArray(ac)||(ac=[ac]),Array.isArray(bc)||(bc=[bc]),ac=ac.filter(nulls),bc=bc.filter(nulls),a["class"]=ac.concat(bc).join(" ");for(var key in b)key!="class"&&(a[key]=b[key]);return a};function nulls(val){return val!=null}return exports.attrs=function attrs(obj,escaped){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):0==key.indexOf("data")&&"string"!=typeof val?buf.push(key+"='"+JSON.stringify(val)+"'"):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):escaped&&escaped[key]?buf.push(key+'="'+exports.escape(val)+'"'):buf.push(key+'="'+val+'"')}}return buf.join(" ")},exports.escape=function escape(html){return String(html).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function rethrow(err,filename,lineno){if(!filename)throw err;var context=3,str=require("fs").readFileSync(filename,"utf8"),lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message,err},exports}({});
// create our folder objects

@@ -22,4 +230,8 @@ exports["otherfolder"] = {};

var buf = [];
var locals_ = locals || {}, content = locals_.content;
buf.push('<div class="page-404">' + jade.escape((jade.interp = content || '404') == null ? '' : jade.interp) + '!</div>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (content) {
buf.push('<div class="page-404">' + jade.escape((jade_interp = content || '404') == null ? '' : jade_interp) + '!</div>');
}('content' in locals_for_with ? locals_for_with.content : typeof content !== 'undefined' ? content : undefined));
return buf.join('');

@@ -31,4 +243,8 @@ };

var buf = [];
var locals_ = locals || {}, tweet = locals_.tweet;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = tweet) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (tweet) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = tweet) ? '' : jade_interp) + '</li>');
}('tweet' in locals_for_with ? locals_for_with.tweet : typeof tweet !== 'undefined' ? tweet : undefined));
return buf.join('');

@@ -40,4 +256,8 @@ };

var buf = [];
var locals_ = locals || {}, tweet = locals_.tweet;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = tweet) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (tweet) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = tweet) ? '' : jade_interp) + '</li>');
}('tweet' in locals_for_with ? locals_for_with.tweet : typeof tweet !== 'undefined' ? tweet : undefined));
return buf.join('');

@@ -49,37 +269,35 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.otherfolder.nestedMixin.user_li(user, i));
i++;
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');
};
// otherfolder/nestedMixin.jade:user_li_mixin compiled template
exports["otherfolder"]["nestedMixin"]["user_li"] = function tmpl_otherfolder_nestedMixin_user_li_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<li" + jade.attrs({
"data-user-id": user.id,
"data-user-index": index
}, {
"data-user-id": true,
"data-user-index": true
}) + ">test</li>");
// otherfolder/nestedMixin.jade:user_li compiled template
exports["otherfolder"]["nestedMixin"]["user_li"] = function tmpl_otherfolder_nestedMixin_user_li(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<li" + jade.attr("data-user-id", user.id, true, false) + jade.attr("data-user-index", index, true, false) + ">test</li>");
return buf.join("");

@@ -91,29 +309,66 @@ };

var buf = [];
var locals_ = locals || {}, user = locals_.user;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (user) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = user) ? '' : jade_interp) + '</li>');
}('user' in locals_for_with ? locals_for_with.user : typeof user !== 'undefined' ? user : undefined));
return buf.join('');
};
// underscoreUsers.jade compiled template
exports["underscoreUsers"] = function tmpl_underscoreUsers(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users, _) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape((jade_interp = _.isObject(user) && _.isString(user.name) ? user.name : '') == null ? '' : jade_interp) + '</li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape((jade_interp = _.isObject(user) && _.isString(user.name) ? user.name : '') == null ? '' : jade_interp) + '</li>');
}
}
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined, '_' in locals_for_with ? locals_for_with._ : typeof _ !== 'undefined' ? _ : undefined));
return buf.join('');
};
// users.jade compiled template
exports["users"] = function tmpl_users(locals) {
var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade_interp = user.name) ? '' : jade_interp) + '</li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade_interp = user.name) ? '' : jade_interp) + '</li>');
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');

@@ -125,37 +380,35 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push(exports.usersMixins.user_li(user, i));
i++;
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');
};
// usersMixins.jade:user_li_mixin compiled template
exports["usersMixins"]["user_li"] = function tmpl_usersMixins_user_li_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<li" + jade.attrs({
"data-user-id": user.id,
"data-user-index": index
}, {
"data-user-id": true,
"data-user-index": true
}) + "><span>Before</span>");
// usersMixins.jade:user_li compiled template
exports["usersMixins"]["user_li"] = function tmpl_usersMixins_user_li(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<li" + jade.attr("data-user-id", user.id, true, false) + jade.attr("data-user-index", index, true, false) + "><span>Before</span>");
buf.push(exports.usersMixins.user_a(user, index));

@@ -166,12 +419,6 @@ buf.push("</li>");

// usersMixins.jade:user_a_mixin compiled template
exports["usersMixins"]["user_a"] = function tmpl_usersMixins_user_a_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<a" + jade.attrs({
href: user.url,
"data-user-index": index
}, {
href: true,
"data-user-index": true
}) + ">Within " + jade.escape((jade.interp = user.name) == null ? "" : jade.interp) + "</a>");
// usersMixins.jade:user_a compiled template
exports["usersMixins"]["user_a"] = function tmpl_usersMixins_user_a(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<a" + jade.attr("href", user.url, true, false) + jade.attr("data-user-index", index, true, false) + ">Within " + jade.escape((jade_interp = user.name) == null ? "" : jade_interp) + "</a>");
return buf.join("");

@@ -183,21 +430,25 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li' + jade.attrs({ 'data-user-id': user.id }, { 'data-user-id': true }) + '><span>Before</span><a' + jade.attrs({ href: user.url }, { href: true }) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a></li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + '><span>Before</span><a' + jade.attr('href', user.url, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a></li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + '><span>Before</span><a' + jade.attr('href', user.url, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a></li>');
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li' + jade.attrs({ 'data-user-id': user.id }, { 'data-user-id': true }) + '><span>Before</span><a' + jade.attrs({ href: user.url }, { href: true }) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a></li>');
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');

@@ -204,0 +455,0 @@ };

@@ -0,1 +1,211 @@

!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jade=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
/**
* Merge two attribute objects giving precedence
* to values in object `b`. Classes are special-cased
* allowing for arrays and merging/joining appropriately
* resulting in a string.
*
* @param {Object} a
* @param {Object} b
* @return {Object} a
* @api private
*/
exports.merge = function merge(a, b) {
if (arguments.length === 1) {
var attrs = a[0];
for (var i = 1; i < a.length; i++) {
attrs = merge(attrs, a[i]);
}
return attrs;
}
var ac = a['class'];
var bc = b['class'];
if (ac || bc) {
ac = ac || [];
bc = bc || [];
if (!Array.isArray(ac)) ac = [ac];
if (!Array.isArray(bc)) bc = [bc];
a['class'] = ac.concat(bc).filter(nulls);
}
for (var key in b) {
if (key != 'class') {
a[key] = b[key];
}
}
return a;
};
/**
* Filter null `val`s.
*
* @param {*} val
* @return {Boolean}
* @api private
*/
function nulls(val) {
return val != null && val !== '';
}
/**
* join array as classes.
*
* @param {*} val
* @return {String}
*/
exports.joinClasses = joinClasses;
function joinClasses(val) {
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
}
/**
* Render the given classes.
*
* @param {Array} classes
* @param {Array.<Boolean>} escaped
* @return {String}
*/
exports.cls = function cls(classes, escaped) {
var buf = [];
for (var i = 0; i < classes.length; i++) {
if (escaped && escaped[i]) {
buf.push(exports.escape(joinClasses([classes[i]])));
} else {
buf.push(joinClasses(classes[i]));
}
}
var text = joinClasses(buf);
if (text.length) {
return ' class="' + text + '"';
} else {
return '';
}
};
/**
* Render the given attribute.
*
* @param {String} key
* @param {String} val
* @param {Boolean} escaped
* @param {Boolean} terse
* @return {String}
*/
exports.attr = function attr(key, val, escaped, terse) {
if ('boolean' == typeof val || null == val) {
if (val) {
return ' ' + (terse ? key : key + '="' + key + '"');
} else {
return '';
}
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
} else if (escaped) {
return ' ' + key + '="' + exports.escape(val) + '"';
} else {
return ' ' + key + '="' + val + '"';
}
};
/**
* Render the given attributes object.
*
* @param {Object} obj
* @param {Object} escaped
* @return {String}
*/
exports.attrs = function attrs(obj, terse){
var buf = [];
var keys = Object.keys(obj);
if (keys.length) {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i]
, val = obj[key];
if ('class' == key) {
if (val = joinClasses(val)) {
buf.push(' ' + key + '="' + val + '"');
}
} else {
buf.push(exports.attr(key, val, false, terse));
}
}
}
return buf.join('');
};
/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/
exports.escape = function escape(html){
var result = String(html)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
if (result === '' + html) return html;
else return result;
};
/**
* Re-throw the given `err` in context to the
* the jade in `filename` at the given `lineno`.
*
* @param {Error} err
* @param {String} filename
* @param {String} lineno
* @api private
*/
exports.rethrow = function rethrow(err, filename, lineno, str){
if (!(err instanceof Error)) throw err;
if ((typeof window != 'undefined' || !filename) && !str) {
err.message += ' on line ' + lineno;
throw err;
}
try {
str = str || _dereq_('fs').readFileSync(filename, 'utf8')
} catch (ex) {
rethrow(err, null, lineno)
}
var context = 3
, lines = str.split('\n')
, start = Math.max(lineno - context, 0)
, end = Math.min(lines.length, lineno + context);
// Error context
var context = lines.slice(start, end).map(function(line, i){
var curr = i + start + 1;
return (curr == lineno ? ' > ' : ' ')
+ curr
+ '| '
+ line;
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'Jade') + ':' + lineno
+ '\n' + context + '\n\n' + err.message;
throw err;
};
},{"fs":2}],2:[function(_dereq_,module,exports){
},{}]},{},[1])
(1)
});
(function () {

@@ -5,5 +215,3 @@ var root = this, exports = {};

// The jade runtime:
var jade = exports.jade=function(exports){Array.isArray||(Array.isArray=function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}),Object.keys||(Object.keys=function(obj){var arr=[];for(var key in obj)obj.hasOwnProperty(key)&&arr.push(key);return arr}),exports.merge=function merge(a,b){var ac=a["class"],bc=b["class"];if(ac||bc)ac=ac||[],bc=bc||[],Array.isArray(ac)||(ac=[ac]),Array.isArray(bc)||(bc=[bc]),ac=ac.filter(nulls),bc=bc.filter(nulls),a["class"]=ac.concat(bc).join(" ");for(var key in b)key!="class"&&(a[key]=b[key]);return a};function nulls(val){return val!=null}return exports.attrs=function attrs(obj,escaped){var buf=[],terse=obj.terse;delete obj.terse;var keys=Object.keys(obj),len=keys.length;if(len){buf.push("");for(var i=0;i<len;++i){var key=keys[i],val=obj[key];"boolean"==typeof val||null==val?val&&(terse?buf.push(key):buf.push(key+'="'+key+'"')):0==key.indexOf("data")&&"string"!=typeof val?buf.push(key+"='"+JSON.stringify(val)+"'"):"class"==key&&Array.isArray(val)?buf.push(key+'="'+exports.escape(val.join(" "))+'"'):escaped&&escaped[key]?buf.push(key+'="'+exports.escape(val)+'"'):buf.push(key+'="'+val+'"')}}return buf.join(" ")},exports.escape=function escape(html){return String(html).replace(/&(?!(\w+|\#\d+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},exports.rethrow=function rethrow(err,filename,lineno){if(!filename)throw err;var context=3,str=require("fs").readFileSync(filename,"utf8"),lines=str.split("\n"),start=Math.max(lineno-context,0),end=Math.min(lines.length,lineno+context),context=lines.slice(start,end).map(function(line,i){var curr=i+start+1;return(curr==lineno?" > ":" ")+curr+"| "+line}).join("\n");throw err.path=filename,err.message=(filename||"Jade")+":"+lineno+"\n"+context+"\n\n"+err.message,err},exports}({});
// create our folder objects

@@ -22,4 +230,8 @@ exports["otherfolder"] = {};

var buf = [];
var locals_ = locals || {}, content = locals_.content;
buf.push('<div class="page-404">' + jade.escape((jade.interp = content || '404') == null ? '' : jade.interp) + '!</div>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (content) {
buf.push('<div class="page-404">' + jade.escape((jade_interp = content || '404') == null ? '' : jade_interp) + '!</div>');
}('content' in locals_for_with ? locals_for_with.content : typeof content !== 'undefined' ? content : undefined));
return buf.join('');

@@ -31,4 +243,8 @@ };

var buf = [];
var locals_ = locals || {}, tweet = locals_.tweet;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = tweet) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (tweet) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = tweet) ? '' : jade_interp) + '</li>');
}('tweet' in locals_for_with ? locals_for_with.tweet : typeof tweet !== 'undefined' ? tweet : undefined));
return buf.join('');

@@ -40,4 +256,8 @@ };

var buf = [];
var locals_ = locals || {}, tweet = locals_.tweet;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = tweet) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (tweet) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = tweet) ? '' : jade_interp) + '</li>');
}('tweet' in locals_for_with ? locals_for_with.tweet : typeof tweet !== 'undefined' ? tweet : undefined));
return buf.join('');

@@ -49,47 +269,39 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
var user_li_mixin = function (user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {};
buf.push('<li' + jade.attrs({
'data-user-id': user.id,
'data-user-index': index
}, {
'data-user-id': true,
'data-user-index': true
}) + '>test</li>');
};
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
user_li_mixin(user, i);
i++;
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
jade_mixins['user_li'] = function (user, index) {
var block = this && this.block, attributes = this && this.attributes || {};
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + jade.attr('data-user-index', index, true, false) + '>test</li>');
};
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
jade_mixins['user_li'](user, i);
i++;
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
jade_mixins['user_li'](user, i);
i++;
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
user_li_mixin(user, i);
i++;
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');
};
// otherfolder/nestedMixin.jade:user_li_mixin compiled template
exports["otherfolder"]["nestedMixin"]["user_li"] = function tmpl_otherfolder_nestedMixin_user_li_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<li" + jade.attrs({
"data-user-id": user.id,
"data-user-index": index
}, {
"data-user-id": true,
"data-user-index": true
}) + ">test</li>");
// otherfolder/nestedMixin.jade:user_li compiled template
exports["otherfolder"]["nestedMixin"]["user_li"] = function tmpl_otherfolder_nestedMixin_user_li(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<li" + jade.attr("data-user-id", user.id, true, false) + jade.attr("data-user-index", index, true, false) + ">test</li>");
return buf.join("");

@@ -101,29 +313,66 @@ };

var buf = [];
var locals_ = locals || {}, user = locals_.user;
buf.push('<li class="tweet">' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (user) {
buf.push('<li class="tweet">' + jade.escape(null == (jade_interp = user) ? '' : jade_interp) + '</li>');
}('user' in locals_for_with ? locals_for_with.user : typeof user !== 'undefined' ? user : undefined));
return buf.join('');
};
// underscoreUsers.jade compiled template
exports["underscoreUsers"] = function tmpl_underscoreUsers(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users, _) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape((jade_interp = _.isObject(user) && _.isString(user.name) ? user.name : '') == null ? '' : jade_interp) + '</li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape((jade_interp = _.isObject(user) && _.isString(user.name) ? user.name : '') == null ? '' : jade_interp) + '</li>');
}
}
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined, '_' in locals_for_with ? locals_for_with._ : typeof _ !== 'undefined' ? _ : undefined));
return buf.join('');
};
// users.jade compiled template
exports["users"] = function tmpl_users(locals) {
var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade_interp = user.name) ? '' : jade_interp) + '</li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade_interp = user.name) ? '' : jade_interp) + '</li>');
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li>' + jade.escape(null == (jade.interp = user) ? '' : jade.interp) + '</li>');
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');

@@ -135,59 +384,45 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
var user_li_mixin = function (user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {};
buf.push('<li' + jade.attrs({
'data-user-id': user.id,
'data-user-index': index
}, {
'data-user-id': true,
'data-user-index': true
}) + '><span>Before</span>');
user_a_mixin(user, index);
buf.push('</li>');
};
var user_a_mixin = function (user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {};
buf.push('<a' + jade.attrs({
href: user.url,
'data-user-index': index
}, {
href: true,
'data-user-index': true
}) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a>');
};
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
user_li_mixin(user, i);
i++;
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
jade_mixins['user_li'] = function (user, index) {
var block = this && this.block, attributes = this && this.attributes || {};
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + jade.attr('data-user-index', index, true, false) + '><span>Before</span>');
jade_mixins['user_a'](user, index);
buf.push('</li>');
};
jade_mixins['user_a'] = function (user, index) {
var block = this && this.block, attributes = this && this.attributes || {};
buf.push('<a' + jade.attr('href', user.url, true, false) + jade.attr('data-user-index', index, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a>');
};
buf.push('<ul>');
var i = 0;
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
jade_mixins['user_li'](user, i);
i++;
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
jade_mixins['user_li'](user, i);
i++;
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
user_li_mixin(user, i);
i++;
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');
};
// usersMixins.jade:user_li_mixin compiled template
exports["usersMixins"]["user_li"] = function tmpl_usersMixins_user_li_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<li" + jade.attrs({
"data-user-id": user.id,
"data-user-index": index
}, {
"data-user-id": true,
"data-user-index": true
}) + "><span>Before</span>");
// usersMixins.jade:user_li compiled template
exports["usersMixins"]["user_li"] = function tmpl_usersMixins_user_li(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<li" + jade.attr("data-user-id", user.id, true, false) + jade.attr("data-user-index", index, true, false) + "><span>Before</span>");
buf.push(exports.usersMixins.user_a(user, index));

@@ -198,12 +433,6 @@ buf.push("</li>");

// usersMixins.jade:user_a_mixin compiled template
exports["usersMixins"]["user_a"] = function tmpl_usersMixins_user_a_mixin(user, index) {
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {}, buf = [];
buf.push("<a" + jade.attrs({
href: user.url,
"data-user-index": index
}, {
href: true,
"data-user-index": true
}) + ">Within " + jade.escape((jade.interp = user.name) == null ? "" : jade.interp) + "</a>");
// usersMixins.jade:user_a compiled template
exports["usersMixins"]["user_a"] = function tmpl_usersMixins_user_a(user, index) {
var block = this && this.block, attributes = this && this.attributes || {}, buf = [], jade_interp;
buf.push("<a" + jade.attr("href", user.url, true, false) + jade.attr("data-user-index", index, true, false) + ">Within " + jade.escape((jade_interp = user.name) == null ? "" : jade_interp) + "</a>");
return buf.join("");

@@ -215,21 +444,25 @@ };

var buf = [];
var locals_ = locals || {}, users = locals_.users;
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li' + jade.attrs({ 'data-user-id': user.id }, { 'data-user-id': true }) + '><span>Before</span><a' + jade.attrs({ href: user.url }, { href: true }) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a></li>');
var jade_mixins = {};
var jade_interp;
var locals_for_with = locals || {};
(function (users) {
buf.push('<ul>');
(function () {
var $$obj = users;
if ('number' == typeof $$obj.length) {
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
var user = $$obj[$index];
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + '><span>Before</span><a' + jade.attr('href', user.url, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a></li>');
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li' + jade.attr('data-user-id', user.id, true, false) + '><span>Before</span><a' + jade.attr('href', user.url, true, false) + '>Within ' + jade.escape((jade_interp = user.name) == null ? '' : jade_interp) + '</a></li>');
}
}
} else {
var $$l = 0;
for (var $index in $$obj) {
$$l++;
var user = $$obj[$index];
buf.push('<li' + jade.attrs({ 'data-user-id': user.id }, { 'data-user-id': true }) + '><span>Before</span><a' + jade.attrs({ href: user.url }, { href: true }) + '>Within ' + jade.escape((jade.interp = user.name) == null ? '' : jade.interp) + '</a></li>');
}
}
}.call(this));
buf.push('</ul>');
}.call(this));
buf.push('</ul>');
}('users' in locals_for_with ? locals_for_with.users : typeof users !== 'undefined' ? users : undefined));
return buf.join('');

@@ -236,0 +469,0 @@ };

@@ -1,2 +0,2 @@

/* globals test, ok, templatizer, templatizer_unaltered, templatizer_multiple_dirs */
/* globals test, ok, templatizer, templatizer_unaltered, templatizer_multiple_dirs, templatizer_globals */

@@ -92,2 +92,9 @@ var data = {

ok(regular({content: 'test'}) !== simple());
});
test("Test that templates work with jade global option", function () {
var users = templatizer.users,
underscoreUsers = templatizer.underscoreUsers;
ok(users({users: data.users}) === underscoreUsers({users: data.users}));
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc