1.0.9 • Published 2 years ago

template-literal-file v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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>
1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago