multiplex-templates
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -8,3 +8,3 @@ 'use strict'; | ||
describe('Embed Service', function () { | ||
describe('Embed Module', function () { | ||
describe('getTemplate()', function () { | ||
@@ -11,0 +11,0 @@ var sandbox; |
// todo: use consolidate.js when it exposes engines and | ||
// allows you to add filters, globals, etc to engine instances before rendering | ||
'use strict'; | ||
var nunjucks = require('nunjucks').configure('.', { | ||
autoescape: true | ||
}), | ||
var nunjucks = require('nunjucks').configure('.', { autoescape: true }), | ||
jade = require('jade'); | ||
// add nunjucks embed filter | ||
nunjucks.addFilter('embed', require('./nunjucks').embedFilter); | ||
module.exports = { | ||
@@ -10,0 +11,0 @@ // expose engines |
{ | ||
"name": "multiplex-templates", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Easy embedding for multiple template languages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -64,2 +64,20 @@ # multiplex-templates | ||
## Cross-engine Embedding | ||
### Nunjucks | ||
To embed a template, use an `embed` filter in the parent template. If you configured your nunjucks environment with `autoescape: true` _[(highly recommended!)](http://wonko.com/post/html-escaping)_, remember to pass the resulting html through `|safe` so it's not escaped. | ||
``` | ||
{{ data | embed('name') | safe }} | ||
``` | ||
The `data` you pass in is then used to render the child template. You can optionally pass in additional data: | ||
``` | ||
{{ data | embed('name', defaults) | safe }} | ||
``` | ||
Properties in the `data` object will overwrite properties of the same name in the `defaults` object, as this uses lodash's fast `_.defaults()` method. | ||
## Tests | ||
@@ -66,0 +84,0 @@ |
'use strict'; | ||
var glob = require('glob'), | ||
_ = require('lodash'), | ||
tests = glob.sync(__dirname + '/../lib/*.test.js'); | ||
tests = glob.sync(__dirname + '/../lib/**/*.test.js'); | ||
@@ -6,0 +6,0 @@ _.map(tests, function (test) { |
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
13473
14
252
86