0.1.1 • Published 10 years ago

templicated v0.1.1

Weekly downloads
2
License
GPL-2.0
Repository
github
Last release
10 years ago

Templicated

NPM version Travis License

Intro

A build step that manages Jade templates for use in JavaScript applications. Here's a demo of it being used.

Installation

via npm

npm i templicated --save

Example build step

var templicated = require('templicated'),
	fs = require('fs');

fs.readFile('app.js', function(e, input) {
	if (e !== null) {
		throw e;
	}

	var code = (
		new templicated.Templicated(input, {
			views: './views/'
		})
	).code;

	fs.writeFile('output.js', code);
});

becomes

var $templicated = (function() {
	function Templicated(tpls) {
		this.tpls = tpls;
	}

	Templicated.prototype['get'] = function(which) {
		return this.tpls[which];
	}

	return new Templicated({"1997400446":"<h1>Hello World</h1>"});
})();

console.log($templicated.get('1997400446'));

Exmaple usuage with Vue

var vm = new Vue({
	el: '#app',
	template: '@tpl.Master'
});

becomes

var $templicated = (function() {
	function Templicated(tpls) {
		this.tpls = tpls;
	}

	Templicated.prototype['get'] = function(which) {
		return this.tpls[which];
	}

	return new Templicated({"1997400446":"<h1>Hello World</h1>"});
})();

var vm = new Vue({
	el: '#app',
	template: $templicated.get('1997400446')
});

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.

.compile(void): Buffer

Returns a Buffer of the new source with Jade templates.

.code: string

Returns a string of the new source with Jade templates.


Build

  • npm i tsc typings -g
  • npm i
  • typings i
  • npm run build

License

GPL-2.0

Copyright(c) 2016 Marais Rossouw

0.1.1

10 years ago

0.1.0

10 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

10 years ago