Created
March 19, 2014 14:10
-
-
Save TechnotronicOz/9642403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //simple example of using lodash/underscore's template method | |
| // update lodash/underscore to use mustache-style interpolations instead of erb | |
| _.templateSettings = { | |
| interpolate: /\{\{(.+?)\}\}/g | |
| }; | |
| // set the template | |
| var template = _.template('<h1>{{title}}</h1><p>{{copy}}</p>'); | |
| // the object that will be passed to the template | |
| var contentObj = { | |
| title: 'The title to be inserted', | |
| copy: 'The copy to be inserted' | |
| } | |
| // add to dom | |
| $('.container').html(template(contentObj)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment