[wp-trac] [WordPress Trac] #23263: Move Media's backbone template regexes

WordPress Trac noreply at wordpress.org
Tue Jan 22 08:09:54 UTC 2013


#23263: Move Media's backbone template regexes
-------------------------+-------------------------
 Reporter:  markjaquith  |       Type:  enhancement
   Status:  new          |   Priority:  normal
Milestone:  3.6          |  Component:  Template
  Version:  3.5          |   Severity:  normal
 Keywords:  needs-patch  |
-------------------------+-------------------------
 Media has custom Backbone templating (because PHP is stupid and sometimes
 parses `<% %>` as PHP code — I know, I know). That templating should be
 available elsewhere instead of being specific to media.

 {{{
                 template: _.memoize( function( id ) {
                         var compiled,
                                 options = {
                                         evaluate:    /<#([\s\S]+?)#>/g,
                                         interpolate:
 /\{\{\{([\s\S]+?)\}\}\}/g,
                                         escape:
 /\{\{([^\}]+?)\}\}(?!\})/g,
                                         variable:    'data'
                                 };

                         return function( data ) {
                                 compiled = compiled || _.template( $(
 '#tmpl-' + id ).html(), null, options );
                                 return compiled( data );
                         };
                 })
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23263>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list