简体   繁体   中英

Php code inside of strange Tags <# #>

I am currently working on a Wordpress page that uses the OnePress theme ( Link ). Inside the customizer-controls.php file I found this:

<div class="widget-content">
    <# var cond_v; #>
    <# for ( i in data ) { #>
    <# if ( ! data.hasOwnProperty( i ) ) continue; #>
    <# field = data[i]; #>
    <# if ( ! field.type ) continue; #>
...

It looks like normal php logic but inside this strange tags <# #>. Can someone tell me what this is?

It's Underscore JS code, but using a Mustache inspired syntax for the tagging.

This is because Underscore's default ERB-style templates are incompatible with PHP when asp_tags is enabled. This means that using <% %> in PHP can break on some sites.

See https://core.trac.wordpress.org/ticket/22344 for more information as to why this is done in WordPress.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM