<# Syntax in WordPress

I was just viewing source of a WordPress Admin Screen and I noticed the <# kind of syntax. Please see the screenshot attached as well. I wanted to know what language or markup is that?enter image description here

Related posts

1 comment

  1. If you look into wp-includes/js/wp-util.js, you’ll find the following function that parse those tags:

    wp.template = _.memoize(function ( id ) {
        var compiled,
            /*
             * Underscore's default ERB-style templates are incompatible with PHP
             * when asp_tags is enabled, so WordPress uses Mustache-inspired templating syntax.
             *
             * @see trac ticket #22344.
             */
            options = {
                evaluate:    /<#([sS]+?)#>/g,
                interpolate: /{{{([sS]+?)}}}/g,
                escape:      /{{([^}]+?)}}(?!})/g,
                variable:    'data'
            };
    
        return function ( data ) {
            compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
            return compiled( data );
        };
    });
    

    As the comment explain, they changed the template tag <% %> to Mustache tags in version 3.5 to avoid any conflict with asp tags.

Comments are closed.