Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

populater

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

populater

Cross platform string syntax for reliably extracting object data

latest
Source
npmnpm
Version
0.5.1
Version published
Maintainers
1
Created
Source
  • Usage

** Basic

#+BEGIN_SRC javascript var populater = require('populater'); var data = { text: "World" };

var context = populater(data); context("Hello {{text}}!") // === "Hello World!";

var template = populater.template("Hello {{text}}!"); template.context(data) // === "Hello World!";

#+END_SRC

** Define a method

#+BEGIN_SRC javascript var populater = require('populater');

populater.method('keys', function() { return Object.keys(this); });

var data = { text: "World" }; var context = populater(data); context("keys()") // === ['text']; #+END_SRC

** Using an alternative context for methods

#+BEGIN_SRC javascript var populater = require('populater');

populater.method('keys', function() { return Object.keys(this); });

var data = { text: "World" }; var altCTX = { 'one': true, 'two': true, 'three': true, };

var context = populater(data, altCTX); context("keys()") // === ['one', 'two', 'three'];

var template = populater.template("keys()"); template.context(data, altCTX) // === ['one', 'two', 'three']; #+END_SRC

FAQs

Package last updated on 05 Oct 2017

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