Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

load-templates

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load-templates

Load templates.

  • 0.10.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

load-templates NPM version Build Status

Load templates.

Install

Install with npm

$ npm i load-templates --save

Usage

In addition to what's shown in the below examples, if a glob pattern or valid filepath is passed, a stat object will be added to the file object as well.

var loader = require('load-templates');
// optionally pass an object to use for caching the views
var cache = {};
var views = loader(cache);

load views from objects

views({
  a: {path: 'a'},
  b: {path: 'b'},
  c: {path: 'c'}
});

from key-value pairs

views('d', {path: 'd'});
views('e', {path: 'e'});
views('f', {path: 'f'});

from globs or file paths

views(['views/*.js']); 

Results

All of the above examples combined result in:

{
  a: {path: 'a'},
  b: {path: 'b'},
  c: {path: 'c'},
  d: {path: 'd'},
  e: {path: 'e'},
  f: {path: 'f'},
  g: {path: 'g'},
  h: {path: 'h'},
  i: {path: 'i'},
  j: {path: 'j'}
}

Options

options.cwd

Special (leading) characters are expanded on options.cwd

  • ~ expands to user home. example: {cwd: '~/foo'}
  • @ expands to global npm modules. example: {cwd: '@/bar'}

options.renameKey

Rename the key of each file object.

Type: Function

Default: noop Full filepath or whatever key is passed.

glob options

All options are also passed to globby.

  • assemble: Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… more
  • templates: System for creating and managing template collections, and rendering templates with any node.js template engine.… more
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more

Running tests

Install dev dependencies:

$ npm i -d && npm test

Coverage summary

As of version 0.10.0

Statements   : 100% (81/81)
Branches     : 100% (44/44)
Functions    : 100% (13/13)
Lines        : 100% (79/79)

Contributing

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

Author

Jon Schlinkert

License

Copyright © 2014-2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on October 09, 2015.

Keywords

FAQs

Package last updated on 09 Oct 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc