multiplex-templates
Advanced tools
Comparing version 0.3.0 to 0.4.0
'use strict'; | ||
var _ = require('lodash'), | ||
template = require('./template'), | ||
engines = {}, | ||
@@ -18,3 +19,3 @@ supported = ['nunjucks', 'jade']; | ||
// add embed filters and mixins | ||
engines.nunjucks.addFilter('embed', require('./nunjucks').embedFilter); | ||
engines.nunjucks.addFilter('embed', template.embed); | ||
@@ -30,3 +31,8 @@ module.exports = { | ||
jade: { | ||
render: engines.jade.renderFile.bind(engines.jade) | ||
render: function (file, options) { | ||
options = options || {}; | ||
// add embed to the locals | ||
options.embed = template.embed; | ||
return engines.jade.renderFile(file, options); | ||
} | ||
} | ||
@@ -33,0 +39,0 @@ }; |
{ | ||
"name": "multiplex-templates", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Easy embedding for multiple template languages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -95,2 +95,19 @@ # multiplex-templates | ||
### Jade | ||
Jade embedding is very similar. Multiplex-templates adds an `embed` function to the options passed into any jade template, which has the same logic as the nunjucks filter. | ||
```jade | ||
section#foo | ||
p.embedded | ||
!= embed(data, 'name') | ||
``` | ||
As with the nunjucks template, you can also pass a `defaults` object into it as a third argument. | ||
```jade | ||
section#foo | ||
p.embedded | ||
!= embed(data, 'name', defaults) | ||
``` | ||
## Tests | ||
@@ -97,0 +114,0 @@ |
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
17287
340
116