2.1.0 • Published 9 years ago

node-partials v2.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

node-partials is an extension of the underscore templating system that adds support for inter-file partials. Partials can be compiled and used on the server as well as serialized to be used on the client.

Setup/example

First lets create a template file called myTemplates.html

## this-is-the-name-of-the-partial
This is some content of the partial

!## this is a comment line ##!
<div class="some class">
	Like some HTML for example
</div>
<div class="some-val">
	<%= foo %>
</div>

Now lets set it up to compile the partial

var partials = require('node-partials');
var templatePath = '/some/path/to/your/templates';

partials = new partials({
	templatePath: templatePath
	delimiter: '## ', 			// defaults to '## ' but can be pretty much whatever you want.
	validFileTypes: ['html'],	// defaults to 'html' only.
	commentStartDelimiter: '!##',
	commentEndDelimiter: '##!',

});

var templates = partials.getCompiledTemplates();

// to get the content of the partial:
templates['myTemplate/this-is-the-name-of-the-partial']({ foo: 'this is a variable' });

In this case, partials is a dictionary of all of your templates indexed by: <file name>/<template name>.

This also supports the nesting of directories, e.g. <directory>/<directory>/<file name>/<template name>

2.1.0

9 years ago

2.1.0-dev2

9 years ago

2.1.0-dev1

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.0

9 years ago

0.1.0

9 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

11 years ago