template-literal-file

1.0.9 • Public • Published

template-literal-file

Have template literals in an own file and compile it to a function.

Usage

Load a template literal file using the renderFile function

const templateFunction = renderFile('./path/to/file.html')

This returns a function which you can pass an Object. The object keys are passed aas variables to the tempalte literal. So if you pass an object with the key myVar you can use this as a variable inside the template literal file

Template literal file

<div>${myVar}</div>

Javascript

import { renderFile } from 'template-literal-file';

const template = renderFile('./test.html');

const html = template({myVar: 'test' });

console.log(html); // <div>test</div>

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.9
    41
    • latest

Version History

Package Sidebar

Install

npm i template-literal-file

Weekly Downloads

45

Version

1.0.9

License

ISC

Unpacked Size

3.63 kB

Total Files

6

Last publish

Collaborators

  • torbs