Skip to content

Instantly share code, notes, and snippets.

@roboli
Created September 9, 2015 14:02
Show Gist options
  • Save roboli/dfa00d44cbedf86580a6 to your computer and use it in GitHub Desktop.
Save roboli/dfa00d44cbedf86580a6 to your computer and use it in GitHub Desktop.
var expect = require('chai').expect,
parse = require('../parser');
describe('Replace Values', function() {
it('should replace values in string with object properties values', function() {
var obj = {
'ab49fd20': {
key_1: 'some data'
},
'9822df87': {
another_key: 'big data',
yet_another_key: 'small data'
}
};
var str = 'This is a string with {{ ab49fd20.key_1 }}, including {{ 9822df87.another_key }} and also {{ ab49fd20.key_2 }}';
var result = parse(obj, str);
expect(result).to.be.equal('This is a string with some data, including big data and also <nothing>');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment