Use Mustache-insipired template tags.

Underscore's default ERB-style templates are incompatible with PHP when asp_tags is enabled. As a result, we've settled on an alternative syntax that should be familiar to devs: Mustache-inspired for interpolating and escaping content, and ERB-inspired for execution.

	`{{{a}}}` - interpolating
	`{{ a }}` - escaping
	`<# a #>` - execution

props rmccue. fixes #22344, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22415 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith
2012-11-07 08:41:17 +00:00
parent 4cf1dbe0f8
commit c0ab768faa
2 changed files with 83 additions and 75 deletions
+8 -2
View File
@@ -58,9 +58,15 @@ window.wp = window.wp || {};
* @return {function} A function that lazily-compiles the template requested.
*/
template: _.memoize( function( id ) {
var compiled;
var compiled,
options = {
evaluate: /<#([\s\S]+?)#>/g,
interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
escape: /\{\{([\s\S]+?)\}\}/g
};
return function( data ) {
compiled = compiled || _.template( $( '#tmpl-' + id ).html() );
compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
return compiled( data );
};
}),