Socket
Book a DemoInstallSign in
Socket

helper-concat

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

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.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

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.

Keywords

concat

FAQs

Package last updated on 15 Mar 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