This package has been deprecated

Author message:

Re-branded to dimples, please use npm i dimples.

templicated

0.1.1 • Public • Published

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 (!== 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

Package Sidebar

Install

npm i templicated

Weekly Downloads

1

Version

0.1.1

License

GPL-2.0

Last publish

Collaborators

  • marais