tonthanhhung / string-templ

Simple String Templating Parser and Formater, for CLI and CODE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

string-templ (pka string-template-extractor)

A reverse version of string substitution from dojo string

Usage

var extractor = require("string-templ"); //throwable is true

var option = {throws: true};

var template = "First eat ${fruit}, then eat ${anotherFruit}";

var sampleString = "First eat apple, then eat lemon";

// The following method calls are equivalent with the result is
// { fruit: 'apple', anotherFruit: 'lemon' }

extractor(option, template, sampleString);

extractor.parse(option, template, sampleString);

extractor(option)(template)(sampleString); // curry function

extractor.parse(option)(template)(sampleString); // curry function

// option.throws (boolean) required when extractor can not parse the string normally
// true: will throw an error
// false: will return null without throwing error

Installation

In your project path:

$ npm install string-templ

Test

$ npm test

CLI (bin)

string-templ	

About

Simple String Templating Parser and Formater, for CLI and CODE


Languages

Language:JavaScript 100.0%