dimples
v0.2.1
Published
A build step that manages Jade templates for use in JavaScript applications.
Downloads
5
Maintainers
Readme
Intro
A build step that manages Pug templates for use in JavaScript applications. Here's a demo of it being used.
Installation
via npm
npm i dimples --save
Example
Input (app.js
)
document.body.innerHTML = '@tpl.Master';
build step
var dimples = require('dimples'),
fs = require('fs');
fs.readFile('app.js', function(e, input) {
if (e !== null) {
throw e;
}
var code = (
new dimples(input, {
views: './views/',
compress: false
})
).code;
fs.writeFile('output.js', code);
});
becomes (output.js
)
var $dimples = (function(d) {
return (d == void 0) ? ({
data: {},
get: function(a) {
return this.data[a];
},
add: function(tpls) {
for (var key in tpls) {
if (tpls.hasOwnProperty(key)) this.data[key] = tpls[key];
}
}
}) : d;
})($dimples);
$dimples.add({1997400449: '<h1>Hello World</h1>'});
document.body.innerHTML = $dimples.get(1997400449);
API
constructor(input: Buffer|string, options: Config)
input
is either a Buffer or a string of the source JavaScript
options
is an object containing 1 required property: views
which is the directory of where to start finding templates. Also specify a compress
property, which will compress the output of the dimples manager.
.compile(void): Buffer
Returns a Buffer of the new source with pug templates.
.code: string
Returns a string of the new source with pug templates.
Build
npm i typscript typings -g
npm i
typings i
npm run build
License
Copyright(c) 2016 Marais Rossouw