extractjs
Extract/interpolate strings.
Usage
Node.js and Browserify
Install from npm
npm install extractjs
var extractjs = extractor = ; var captured = ;// > { name: 'extractjs'}
Template Settings
Default Settings
var defaults = startExtract: '{' endExtract: '}' extractors: /* capture functions */ initValue: void 0
Templates can be redefined as below:
var extractjs = settings = startExtract: '[[' endExtract: ']]' extractor = ; var captured = ;// > { name: 'John', age: 26 } <-- age is no longer string // Settings can be overridden at the time of extractionvar date = // > { date: 26, month: 4, year: 2015 }
Its possible to build a pattern before extract/interpolate data.
var extractjs = extractor = ; var loginPattern = ; var name = loginPattern name;// > John var output = loginPattern;//> You are loggin in as John.
extractors are used to override or manipulate captured values.
var extractjs = settings = extractors: { var names = value; return firstName: names0 lastName: value fullName: value ; } extractor = ; var captured = ;// > { name: {// firstName: 'John',// lastName: 'Wesley',// fullName: 'John Wesley'// }, age: 26 }
Web page
Access from window/global as extractjs.
License
This plugin is licensed under the MIT license.
Copyright (c) 2015 Prince John Wesley