From 9329d742cb8a81fa52821220676fca22e8f1d9e6 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Wed, 7 Nov 2012 08:41:17 +0000 Subject: [PATCH] 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: http://core.svn.wordpress.org/trunk@22415 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-models.js | 10 ++- wp-includes/media.php | 148 +++++++++++++++++---------------- 2 files changed, 83 insertions(+), 75 deletions(-) diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index e9776b4840..36e2d436f7 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -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 ); }; }), diff --git a/wp-includes/media.php b/wp-includes/media.php index 5144f5df6e..7ef9f7e1df 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1296,7 +1296,7 @@ function wp_print_media_templates( $attachment ) { ?>