dim

dimples

A build step that manages Jade templates for use in JavaScript applications.

Showing:

Popularity

Downloads/wk

1

GitHub Stars

0

Maintenance

Last Commit

5yrs ago

Contributors

1

Package

Dependencies

4

Size (min+gzip)

256.1KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Dimples

JavaScript and HTML templates can be just as cute as pair of dimples!

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial