Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#37265 closed defect (bug) (invalid)

underscorejs Escaping Issues

Reported by: casben79 Owned by:
Priority: normal Milestone:
Component: General Version: 4.5.3
Severity: normal Keywords:
Cc: Focuses:

Description

I am attempting to customise a WooCommerce single variation template which uses the WP underscore.js setup.

The following is throwing a JS error: Uncaught SyntaxError: Unexpected token ) in underscores.min.js

<div class="attributes">

    {{{ _.each( data.variation.attribute_data, function(element, index, list) { }}}

        <span class="test">TEST</span>

    {{{ }); }}}

</div>

If I change it to the following it works fine, I just need to escape into HTML for the templating.

<div class="attributes">

    {{{ _.each( data.variation.attribute_data, function(element, index, list) { 
        
        console.log( element );
            
    }); }}}

</div>

Change History (1)

#1 @adamsilverstein
10 years ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed

Hello @casben79 thanks for the bug report. I don't think this is a WordPress core issue, and this trac is for reporting bugs in WordPress core.

I think you are using {{{ incorrectly, this is for unescaped output. if you want to run raw JS, i think you want <% %> for straight underscore (or are you using wp.template?).

Closing this ticket as invalid, feel free to hit me up in Slack and I may be able to help you troubleshoot.

Note: See TracTickets for help on using tickets.