$ npm install 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.
npm i helper-concat --save
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'}}
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'}}
This should work with any template engine, here are a few examples
Register the helper for use with any template engine
template.helper('concat', require('helper-concat'));
To register the helper for use with assemble v0.6.x:
assemble.helper('concat', require('helper-concat'));
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('./'));
});
var handlebars = require('handlebars');
handlebars.registerHelper('concat', require('helper-concat'));
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'
Install dev dependencies.
npm i -d && npm test
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.
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on March 15, 2015.
© 2010 - cnpmjs.org x YWFE | Home | YWFE