1.0.3 • Published 6 years ago

nucly-template-loader v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

nucly-template-loader

npm npm

Installation

npm i nucly-template-loader

Usage

const templateLoader = require('nucly-template-loader');

loaders: [
	templateLoader(options)
]

Selection

By default, the loader will handle all files that end with .html The function to test this can be changed using the test option:

templateLoader({
	test: filename => /\.html$/.test(filename)
})

Extending Context

The context that is passed to each template can be extended using the context option. All properties from the passed object will be assigned to the compile context.

templateLoader({
	context: {
		message: 'Hello World!'
	}
})
<h1><%= message %></h1>

Including Resources

Any resource that implements an include function can be included. Relative paths are relative to the current template.

<%- await include('heading.html', {text: 'Hello World!'}) %>

<!-- heading.html -->
<h1><%= text %></h1>

Custom Syntax

A syntax configuration can be passed with the syntax option. For syntax configuration options see here

templateLoader({
	syntax: {
		// Syntax configuration.
	}
})
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago