helpers/helper-read

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

helper-read NPM version

Template helper for reading from the file system. Includes both async and sync versions.

Install

Install with npm

i helper-read --save
Usage
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'

Related projects
Running tests

Install dev dependencies:

i -d && npm test
Contributing

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

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on May 11, 2015.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.