toddmotto/interpolate — pull request #4 by krasimir (2014-07-08 22:03:50+00:00)
Title: Extending the template capabilities

I was playing with [similar library](http://krasimirtsonev.com/blog/article/Javascript-template-engine-in-just-20-line) and ended up with the idea that the expressions between `{{` and `}}` should accept more then just strings. Once I started using the module I caught myself writing lots of code that formats the data. Instead of writing these parts externally, for me it makes sense to add them into the template. For example:
```js
var render = interpolate('Author: {{ fullName() }}.');
var data = {
firstName: 'Todd',
lastName: 'Motto',
fullName: function() {
return this.firstName + ' ' + this.lastName;
}
}
```
So, the library accepts not only a valid path to property but pure JavaScript. Here is another example:
```js
render = interpolate("Author: {{ age > 30 ? fullName() : fullName().toUpperCase() }}.");
var data = {
age: 23,
firstName: 'Todd',
lastName: 'Motto',
fullName: function() {
return this.firstName + ' ' + this.lastName;
}
}
```

P.S.
I guess that the idea of this project is to be as simple as possible. So, feel free to reject my PR if the changes are adding too complex logic.