JSPM

compile-template

0.3.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8786
  • Score
    100M100P100Q114269F
  • License MIT

📠 Micro templates for Node.js

Package Exports

  • compile-template

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compile-template) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM Version node Build Status js-standard-style

compile-template

📠 Micro templates for Node.js

js template literals + node vm = profit

Captain obvious alert: 🚨 The node vm module is not a security mechanism. Do not use untrusted code in templates.

Installation

Install from NPM:

$ npm install compile-template --save

Note: compile-template requires Node 4.0.0 or later

Example

const compile = require('compile-template')

const template = compile('foo=${41+value}')
const string = template({value: 1})
assert(string === 'foo=42')

const template = compile('foo=${41+value}', {value: 1})
assert(template() === 'foo=42')