stubble.js was conceived in need for a way to late-bind localized strings to properties of an object, prior to pretty-printing with mustache.js. It may be useful for other purposes.
stubble()
will copy property-value pairs from a source
to a target
with some mapping and localization. In the code below, we setup a source and a target, then copy a localized property-value pair into the target:
var localizedStrings = {
dayOfWeek_name_en: 'Sunday Monday Tuesday etc.'.split(),
};
var datum = { dayOfWeek: 1 };
datum.stubble({source:localizedStrings, language:'en'});
After this, datum.dayOfWeek_name == 'Monday'
.
On *nix:
cat src/* > stubble.js
or at a DOS prompt:
type src\* > stubble.js
stubble.js
is under src
. Jasmine specifications are under spec
.
Collaborators welcome. Feel free to fork the github project and send pull requests.
Copyright © 2011 Joshua Tacoma. This software is licensed under the MIT License.