backtick (`) templates
tiny template engine using JavaScript's built-in template strings
NOTE: this is probably NOT SAFE FOR UNTRUSTED INPUT
install with
npm install backplate
or
yarn add backplate
and import with
const { compile, render } = require('backplate')
or
import { compile, render } from 'backplate'
import { compile, render } from 'https://denopkg.com/ahdinosaur/backplate@main/src/mod.ts'
template = compile(source)
const source = 'Hello ${world}!'
const template = compile(source)
const data = { world: 'Earth' }
const string = template(data)
console.log(string)
// Hello Earth!
render(source, data)
const source = 'Hello ${world}!'
const data = { world: 'Earth' }
const string = render(source, data)
console.log(string)
// Hello Earth!