helper-concat
Template helper for concatenating a list of files using glob patterns. Should work with handlebars, lodash or any template engine that allows helper functions.
Last updated 10 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install helper-concat 
SYNC missed versions from official npm registry.

helper-concat NPM version Build Status

Template helper for concatenating a list of files using glob patterns. Should work with handlebars, lodash or any template engine that allows helper functions.

Install with npm

npm i helper-concat --save

Usage examples

concat

Get the contatenated content from a glob of files.

  • patterns {String}
  • options {Options}
  • returns: {String}
var concat = require('helper-concat');

concat('files/*.md', function(err, content) {
  //=> 'AAA\nBBB\nCCC'
});

As a helper:

{{concat 'files/*.md'}}

.sync

Synchronously get the contatenated content from a glob of files.

  • patterns {String}
  • options {Options}
  • returns: {String}
var concat = require('helper-concat');

concat('files/*.md');
//=> 'AAA\nBBB\nCCC'

As a helper:

{{concat 'files/*.md'}}

Register the helper

This should work with any template engine, here are a few examples

template

Register the helper for use with any template engine

template.helper('concat', require('helper-concat'));

assemble

To register the helper for use with assemble v0.6.x:

assemble.helper('concat', require('helper-concat'));

verb

Register the helper for use with verb:

var verb = require('verb');
verb.helper('concat', require('helper-concat'));

verb.task('default', function() {
  verb.src('.verb*.md')
    .pipe(verb.dest('./'));
});

handlebars

var handlebars = require('handlebars');
handlebars.registerHelper('concat', require('helper-concat'));

Lo-Dash or underscore

var handlebars = require('handlebars');
handlebars.registerHelper('concat', require('helper-concat'));

// as a mixin
_.mixin({concat: concatHelper});
_.template('<%= _.concat("fixtures/*.txt") %>', {});
//=> 'AAA\nBBB\nCCC'

// passed on the context
var settings = {imports: {concat: concatHelper}};
_.template('<%= concat("fixtures/*.txt") %>', {concat: concatHelper});
//=> 'AAA\nBBB\nCCC'

// as an import
var settings = {imports: {concat: concatHelper}};
_.template('<%= concat("fixtures/*.txt") %>', {}, settings);
//=> 'AAA\nBBB\nCCC'

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

To request or contribute a helper to the github.com/helpers org, please read this contributing guide to get started.

Author

Jon Schlinkert

License

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


This file was generated by verb-cli on March 15, 2015.

Current Tags

  • 0.3.0                                ...           latest (10 years ago)

3 Versions

  • 0.3.0                                ...           10 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (4)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE