A dust helper to load internationalized strings for display
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.eslintrc
.gitignore
.jshintrc
.travis.yml
LICENSE.txt
README.md
index.js
package.json

README.md

dust-usecontent-helper

A dustjs helper to load content bundles into the context for use by the @message helper or the formatjs message helper.

Build Status

Example use

var dustjs = require('dustjs-linkedin');
var helper = require('dustjs-usecontent-helper');
var messagehelper = require('dustjs-message-helper');
helper(function (context, bundleName, cb) {
    if (bundleName == 'test.properties') {
        cb(null, {hello: "world"});
    } else {
        cb(new Error("not found"));
    }
}).registerWith(dustjs);
messagehelper.registerWith(dustjs);

dustjs.render('sometemplate', {}, function (err, result) {
    console.log(err, result);
});

And a template like this

{@useContent bundle="test.properties"}
    {@message key="hello" /}
{/useContent}

should return the string "world"