Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 442
Sören Oehding Avatar asked Jan 29 '26 22:01

Sören Oehding


1 Answers

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.

like image 171
Otto Avatar answered Jan 31 '26 12:01

Otto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!