Skip to content

Simple String Templating Parser and Formater, for CLI and CODE

Notifications You must be signed in to change notification settings

gratex/string-templ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published