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

multiplex-templates

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiplex-templates - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

lib/nunjucks/index.js

2

lib/embed.test.js

@@ -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) {

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