Make WordPress Core

Ticket #23263: 23263.2.diff

File 23263.2.diff, 1.9 KB (added by wonderboymusic, 11 years ago)
  • new file wp-includes/js/template.js

    diff --git wp-includes/js/template.js wp-includes/js/template.js
    new file mode 100644
    index 0000000..8b4e818
    - +  
     1window.wp = window.wp || {};
     2
     3(function ($) {
     4        var template;
     5        /**
     6         * wp.template( id )
     7         *
     8         * Fetches a template by id.
     9         *
     10         * @param  {string} id   A string that corresponds to a DOM element with an id prefixed with "tmpl-".
     11         *                       For example, "attachment" maps to "tmpl-attachment".
     12         * @return {function}    A function that lazily-compiles the template requested.
     13         */
     14        template = wp.template = _.memoize(function ( id ) {
     15                var compiled,
     16                        options = {
     17                                evaluate:    /<#([\s\S]+?)#>/g,
     18                                interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
     19                                escape:      /\{\{([^\}]+?)\}\}(?!\})/g,
     20                                variable:    'data'
     21                        };
     22
     23                return function ( data ) {
     24                        compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
     25                        return compiled( data );
     26                };
     27        });
     28
     29}(jQuery));
     30 No newline at end of file
  • wp-includes/script-loader.php

    diff --git wp-includes/script-loader.php wp-includes/script-loader.php
    index cfb865e..f208c09 100644
    function wp_default_scripts( &$scripts ) { 
    270270        $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2011-02-23');
    271271
    272272        $scripts->add( 'underscore', '/wp-includes/js/underscore.min.js', array(), '1.4.4', 1 );
    273         $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery'), '0.9.2', 1 );
     273        $scripts->add( 'template', "/wp-includes/js/template$suffix.js", array('underscore'), '1.0', 1 );
     274        $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery', 'template'), '0.9.2', 1 );
    274275
    275276        $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 );
    276277