Flexible templates parser inspired by gulp-file-include.
$ npm i meta-templater
Template has three types of constructions:
//= var_name
Where //=
is prefix and suffix is empty
//= include[]
Where include
is fn
name and []
is argument js object (array)
//= print ( content )
//= each[] ()
Where arguments is optinal and ()
is body of op
compile.js
var MT = require('meta-templater'),
fs = require('fs');
var result = new MT().build(fs.readFileSync('src/index.html', 'utf-8'), {
param1: true,
param2: 'John'
});
fs.writeFileSync('dist/index.html', result, 'utf-8');
index.html
//= if[data.voice] (
<div>Hello, //= name</div>
)
index.html
<html>
//= include['head.html', {title: 'Page Title'}]
<body>
//= include['header.html']
//= include['content-main.html']
//= include['footer.html']
</body>
</html>
head.html
<!-- Empty string for indent correction -->
<head>
<meta charset="utf-8">
<title>//= title</title>
</head>
Initialize templater
Type: String
Default: //=
Type: String
Default: ``
Type: String
Default: (
Type: String
Default: )
this
methods##License
Copyright © 2015 Bogdan Chadkin