templatizer
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -63,3 +63,5 @@ 'use strict'; | ||
function joinClasses(val) { | ||
return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val; | ||
return (Array.isArray(val) ? val.map(joinClasses) : | ||
(val && typeof val === 'object') ? Object.keys(val).filter(function (key) { return val[key]; }) : | ||
[val]).filter(nulls).join(' '); | ||
} | ||
@@ -91,2 +93,12 @@ | ||
exports.style = function (val) { | ||
if (val && typeof val === 'object') { | ||
return Object.keys(val).map(function (style) { | ||
return style + ':' + val[style]; | ||
}).join(';'); | ||
} else { | ||
return val; | ||
} | ||
}; | ||
/** | ||
@@ -102,2 +114,5 @@ * Render the given attribute. | ||
exports.attr = function attr(key, val, escaped, terse) { | ||
if (key === 'style') { | ||
val = exports.style(val); | ||
} | ||
if ('boolean' == typeof val || null == val) { | ||
@@ -110,6 +125,20 @@ if (val) { | ||
} else if (0 == key.indexOf('data') && 'string' != typeof val) { | ||
if (JSON.stringify(val).indexOf('&') !== -1) { | ||
console.warn('Since Jade 2.0.0, ampersands (`&`) in data attributes ' + | ||
'will be escaped to `&`'); | ||
}; | ||
if (val && typeof val.toISOString === 'function') { | ||
console.warn('Jade will eliminate the double quotes around dates in ' + | ||
'ISO form after 2.0.0'); | ||
} | ||
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, ''') + "'"; | ||
} else if (escaped) { | ||
if (val && typeof val.toISOString === 'function') { | ||
console.warn('Jade will stringify dates in ISO form after 2.0.0'); | ||
} | ||
return ' ' + key + '="' + exports.escape(val) + '"'; | ||
} else { | ||
if (val && typeof val.toISOString === 'function') { | ||
console.warn('Jade will stringify dates in ISO form after 2.0.0'); | ||
} | ||
return ' ' + key + '="' + val + '"'; | ||
@@ -116,0 +145,0 @@ } |
{ | ||
"name": "templatizer", | ||
"description": "Simple solution for compiling jade templates into vanilla JS functions for blazin' fast client-side use.", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -24,5 +24,5 @@ "bin": "./bin/cli", | ||
"jade": "^1.7.0", | ||
"lodash": "^3.2.0", | ||
"minimist": "^0.1.0", | ||
"uglify-js": "^2.4.0", | ||
"underscore": "^1.5.1", | ||
"walkdir": "0.0.7" | ||
@@ -38,2 +38,3 @@ }, | ||
"testee": "^0.1.1", | ||
"underscore": "^1.7.0", | ||
"yetify": "0.1.0" | ||
@@ -54,11 +55,11 @@ }, | ||
"scripts": { | ||
"benchmark": "node benchmark/speedtest.js", | ||
"browserify": "./node_modules/.bin/browserify test/browserify-test.js > test/tests-bundle.js", | ||
"build": "npm run copy-runtime && node build.js", | ||
"copy-runtime": "cp node_modules/jade/lib/runtime.js jaderuntime.js", | ||
"copy-underscore": "cp node_modules/underscore/underscore.js test/underscore.js", | ||
"benchmark": "node benchmark/speedtest.js", | ||
"build": "npm run copy-runtime && node build.js", | ||
"browserify": "./node_modules/.bin/browserify test/browserify-test.js > test/tests-bundle.js", | ||
"setup-test": "npm run build && npm run browserify && npm run copy-underscore", | ||
"test": "npm run setup-test && testee test/index.html", | ||
"start": "npm run setup-test && http-server -p 3003 test/" | ||
"start": "npm run setup-test && http-server -p 3003 test/", | ||
"test": "npm run setup-test && testee test/index.html" | ||
} | ||
} |
@@ -9,3 +9,3 @@ var jade = require('jade'); | ||
var util = require('util'); | ||
var _ = require('underscore'); | ||
var _ = require('lodash'); | ||
var fs = require('fs'); | ||
@@ -12,0 +12,0 @@ var uglifyjs = require('uglify-js'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29843
591
9
+ Addedlodash@^3.2.0
+ Addedlodash@3.10.1(transitive)
- Removedunderscore@^1.5.1
- Removedunderscore@1.13.7(transitive)