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)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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 usingwp.template?).Closing this ticket as invalid, feel free to hit me up in Slack and I may be able to help you troubleshoot.