Giter Site home page Giter Site logo

robloach / engines Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonschlinkert/engines

0.0 3.0 0.0 257 KB

Template engine library with fast, synchronous rendering, based on consolidate.

Home Page: https://github.com/jonschlinkert

License: MIT License

JavaScript 100.00%

engines's Introduction

engines

Template engine library with fast, synchronous rendering, based on consolidate.

Installation

$ npm install engines

Supported template engines

Engines with strikethroughs are not yet supported or need to be updated. Pull requests to update them are welcome.

NOTE: you must still install the engines you wish to use, add them to your package.json dependencies.

API

All templates supported by this library may be rendered using the signature (path[, context], callback) as shown below, which is the same signature that Assemble and express support, so any of these engines may be used within Assemble or express.

NOTE: All of the examples use engines.handlebars for the Handlebars template engine. Replace handlebars with whatever template engine you prefer. For example, use engines.hogan for hogan.js, engines.jade for jade, etc.

Run console.log(engines) for the full list of identifiers.

Examples:

var engines = require('engines');
engines.handlebars('templates/about.hbs', { title: 'About Us' }, function(err, html) {
  if (err) { throw err; }
  console.log(html);
});

Or without options / local variables:

var engines = require('engines');
engines.handlebars('templates/about.hbs', function(err, html) {
  if (err) { throw err; }
  console.log(html);
});

To dynamically pass the engine, use the subscript operator and a variable:

var engines = require('engines');
var name = 'handlebars';

engines[name]('templates/about.hbs', { title: 'About Us' }, function(err, html) {
  if (err) { throw err; }
  console.log(html);
});

Caching

To enable caching pass { cache: true }. Engines may use this option to cache things reading the file contents, like compiled Functions etc. Engines which do not support this may simply ignore it. All engines that engines implements I/O for will cache the file contents, as this is ideal for production environments.

var engines = require('engines');
engines.handlebars('templates/about.hbs', { title: 'About Us' }, function(err, html) {
  if (err) { throw err; }
  console.log(html);
});

Assemble v0.6.x example

Run npm install assemble/assemble#v0.6.0, then in your assemblefile.js, add the following:

var assemble = require('assemble');
var engines = require('..');

assemble.engine('hbs', engines.handlebars);

assemble.task('default', function() {
  assemble.src('docs/*.hbs')
    .pipe(assemble.dest('dist'));
});

Running tests

Install dev dependencies:

npm install -d && mocha

License

Copyright (c) 2014 Jon Schlinkert, contributors. Copyright (c) 2011 TJ Holowaychuk <[email protected]>

Released under the MIT license.

engines's People

Contributors

jonschlinkert avatar doowb avatar tombyrer avatar

Watchers

Rob Loach avatar James Cloos avatar  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.