🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

helper-read

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

helper-read

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

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

helper-read NPM version

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

Install

Install with npm

npm i helper-read --save

Usage

var read = require('helper-read');

Usage with lodash

var ctx = {read: read.sync};
_.template('<%= read("fixtures/a.txt") %>')(ctx);
//=> 'AAA'
_.template('<%= read("fixtures/b.txt") %>')(ctx);
//=> 'BBB'

Usage with Template

var read = require('helper-read');
var Template = require('template');
var template = new Template();

/**
 * Register an engine
 */

template.engine('foo', require('engine-lodash'));

/**
 * Register the helper
 */

template.asyncHelper('read', read);

/**
 * Add some templates
 */

template.page('abc.foo', '<%= read("fixtures/a.txt") %>');
template.page('xyz.foo', '<%= read("fixtures/b.txt") %>');

/**
 * Render the templates
 */

template.render('abc.foo', function (err, contents) {
  if (err) console.log(err);
  console.log(contents);
  //=> 'AAA'
});

template.render('xyz.foo', function (err, contents) {
  if (err) console.log(err);
  console.log(contents);
  //=> 'BBB'
});
  • assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more
  • template: Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… more
  • template-helpers: Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… more
  • verb: Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… more

Running tests

Install dev dependencies:

npm 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.

Keywords

assemble

FAQs

Package last updated on 12 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts