0.2.1 • Published 8 years ago

dimples v0.2.1

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

NPM version Travis Codecov License

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

MIT

Copyright(c) 2016 Marais Rossouw

0.2.1

8 years ago

0.2.0

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago