Name: helper-read
Owner: Helpers
Description: Template helper for reading from the file system. Includes both async and sync versions.
Created: 2015-05-12 02:38:50.0
Updated: 2015-05-12 04:18:06.0
Pushed: 2015-05-12 02:39:12.0
Homepage: null
Size: 104
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Template helper for reading from the file system. Includes both async and sync versions.
Install with npm
i helper-read --save
read = require('helper-read');
Usage with lodash
ctx = {read: read.sync};
mplate('<%= read("fixtures/a.txt") %>')(ctx);
'AAA'
mplate('<%= read("fixtures/b.txt") %>')(ctx);
'BBB'
Usage with Template
read = require('helper-read');
Template = require('template');
template = new Template();
egister an engine
late.engine('foo', require('engine-lodash'));
egister the helper
late.asyncHelper('read', read);
dd some templates
late.page('abc.foo', '<%= read("fixtures/a.txt") %>');
late.page('xyz.foo', '<%= read("fixtures/b.txt") %>');
ender the templates
late.render('abc.foo', function (err, contents) {
(err) console.log(err);
nsole.log(contents);
=> 'AAA'
late.render('xyz.foo', function (err, contents) {
(err) console.log(err);
nsole.log(contents);
=> 'BBB'
Install dev dependencies:
i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 11, 2015.