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

template

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

template

An easy-to-use utility library for processing Lo-dash templates.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

template NPM version

An easy-to-use Lo-Dash template processing library.

Quickstart

Install with npm:

npm i template --save

Methods

template

By default the template() method expects the following parameters:

template(text, data, [options])

For example, the following:

var template = require('template');

template('Name: <%= name %>', {name: 'Jon'});

results in:

Name: Jon

template.read

To read a file from the file system before processing, use template.read:

template.read('file.md', data, options);

template.copy

A convenience method for synchronously copying files from A to B.

template.copy(src, dest, data, options);

Pass {process: false} to the options disable template processing.

Options

custom delimiters

All of the options from the delims library may be passed to the options object.

For example, this:

template('Hi, my name is {%= name %}', {name: 'Jon Schlinkert'}, {delims: ['{%', '%}']});

Results in:

Hi, my name is Jon Schlinkert

Valid templates

Any of the following expressions may be used in templates:

// Strings
"foo"

// Property strings
foo
foo.bar
foo.bar.baz

// Method calls, passed as properties on the data object
one()
two.three()

// Lo-Dash Mixins
_.foo()
_.foo(bar)
_.foo("baz")

Authors

Jon Schlinkert

Brian Woodward

License

Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors. Released under the MIT license

Keywords

FAQs

Package last updated on 28 Jan 2014

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