mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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:
@@ -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 );
|
||||
};
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user