Giter Club home page Giter Club logo

dusterjs's Introduction

Duster.js - Node script to watch & precompile directory of dustjs templates

A simple Node script Duster.js to watch a directory of .dust templates and compile them into .js files which can be included into an HTML file.

Why? The dust.js documentation does not mentioned a clear way to work with dust templates in a purely client-side approach, instead focusing on server-side node.js applications.

For my backbone.js app, the only option was to include the dust-full.js file and compile the templates on each browser load. The file is much larger than the normal dust-core.js and this approach provides no extra value over other templating solutions (performance, browser caching, external file management etc).

So I wrote a script to pre-compile dust.js files whenever they are modified in a folder.

Install

Download duster.js to your project root folder and install dependencies:

npm install dustjs-linkedin
npm install watch

Usage

Create dust.js templates in ./src/dusts/ with the file extension .dust and create ./public/dusts directory where files will be compiled to, then run watcher script:

$ node duster.js

You can modify folder paths in the duster.js file

Example:

./src/dusts/tweet.dust
./src/dusts/user.dust

Compiles to:

./public/dusts/tweet.js
./public/dusts/user.js

Then you include them in the html:

<script src="dust-core-1.0.0.min.js"></script>
<script src="tweet.js"></script>
<script src="user.js"></script>

I then use Jammit to concatenate all the JS files before production deployment.

by Dan McGrady http://dmix.ca

dusterjs's People

Contributors

chrisdew avatar aharris avatar ffissore avatar jkrehm avatar stereokai avatar

Watchers

James Cloos avatar Zheng Shen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.