A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jonschlinkert/template below:

jonschlinkert/template: Render templates from any engine. Make custom template types, use layouts on pages, partials or any custom template type, custom delimiters, helpers, middleware, routes, loaders, and lots more. Powers Assemble v0.6.0, Verb v0.3.0 and your application.

Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template helpers, middleware, routes, loaders, and lots more. Powers assemble, verb and other node.js apps.

Here is a brief example of what you can do with Template.

var app = require('template')();
app.engine('tmpl', require('engine-lodash'));

/**
 * Create a custom view collection
 */
app.create('pages');

/**
 * Load views onto the collection (globs work too)
 */

app.page('welcome.tmpl', {path: 'welcome.tmpl', content: 'Hello, <%= name %>!'})
  .page('goodbye.tmpl', {path: 'goodbye.tmpl', content: 'Goodbye, <%= name %>!'});

// get a template
var page = app.pages.get('welcome.tmpl');

// render the template
page.render({name: 'Bob'}, function (err, res) {
  if (err) return console.log(err);
  console.log(res.content);
  //=> 'Hello, Bob!'

  app.pages.get('goodbye.tmpl')
    .render({name: 'Bob'}, function (err, res) {
      if (err) return console.log(err);
      console.log(res.content);
      //=> 'Goodbye, Bob!'
    });
});

Docs are on the way. In the meantime, visit the examples and unit tests to learn more about what Template can do.

Install with npm

See to the API documentation.

Create a new instance of Template with the given `options.

Params

Example

var app = require('template')();

Load data onto app.cache.data

Params

Example

console.log(app.cache.data);
//=> {};

app.data('a', 'b');
app.data({c: 'd'});
console.log(app.cache.data);
//=> {a: 'b', c: 'd'}

Create a new Views collection.

Params

Example

app.create('foo');
app.foo('*.hbs');
var view = app.foo.get('baz.hbs');

Handle middleware for the given view and locals.

Params

Example

app.handle('customHandle', view);

Compile content with the given locals.

Params

Example

var blogPost = app.post('2015-09-01-foo-bar');
var view = app.compile(blogPost);
// view.fn => [function]

Render content with the given locals and callback.

Params

Example

var blogPost = app.post('2015-09-01-foo-bar');
app.render(blogPost, function(err, view) {
  // `view` is an object with a rendered `content` property
});

Install dev dependencies:

Install devDependencies:

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Jon Schlinkert

Copyright © 2014-2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on October 31, 2015.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4