🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More →
Socket
Book a DemoSign in
Socket

tpl_apply

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tpl_apply

tpl_apply with handlebars

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
48
-22.58%
Maintainers
1
Weekly downloads
 
Created
Source

tpl_apply

tpl_apply with handlebars

npm version

Install

npm install --save tpl_apply

Test

npm test

Usage

方式1 :basic

var tpl = require('./index');


var source = process.cwd() + '/tpl.js'
var dest = process.cwd() + '/test/tpl.generate.js'


tpl.tpl_apply(source, {
	title: "My New Post", body: "This is my first post!"
}, dest);

方式2 :with helpers

source = process.cwd() + '/tpl2.js'
dest = process.cwd() + '/test/tpl2.generate.js'

var Handlebars = require('handlebars');

Handlebars.registerHelper('list', function(items, options) {
  var out = "<ul>";

  for(var i=0, l=items.length; i<l; i++) {
    out = out + "<li>" + options.fn(items[i]) + "</li>";
  }

  return out + "</ul>";
});


tpl.tpl_apply_with_register_helper(Handlebars, source, {
  people: [
   {firstName: "Yehuda", lastName: "Katz"},
   {firstName: "Carl", lastName: "Lerche"},
   {firstName: "Alan", lastName: "Johnson"}
 ]
}, dest);

FAQs

Package last updated on 07 Jun 2016

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