Skip to content

fix: resolve template literal syntax error in add_product.html#1064

Open
torbenbrodt wants to merge 1 commit intoprebid:mainfrom
affinity-com:fix/template-literal-syntax-error
Open

fix: resolve template literal syntax error in add_product.html#1064
torbenbrodt wants to merge 1 commit intoprebid:mainfrom
affinity-com:fix/template-literal-syntax-error

Conversation

@torbenbrodt
Copy link

Summary

Fixes a JavaScript Invalid or unexpected token error on the Add Product page caused by incorrect double-backslash escaping of template literals inside a Jinja2 <script> block.

Problem

In templates/add_product.html, JavaScript template literals in addPricingOption() and removePricingOption() were written with escaped backticks and \${index} interpolations. Since Jinja2 does not process content inside <script> tags (only {{ }} / {% %} delimiters are parsed), the backslashes were rendered literally into the JavaScript output, causing a syntax error at runtime.

Fix

Removed the incorrect backslash escaping so plain ES6 template literals are used:

Before:

window[`updatePricingFields\${index}`] = function() {
    const pricingModel = document.querySelector(`select[name="pricing_model_\${index}"]`).value;

After:

window[`updatePricingFields${index}`] = function() {
    const pricingModel = document.querySelector(`select[name="pricing_model_${index}"]`).value;

Files Changed

  • templates/add_product.html — 20 lines (backslash escaping removed from template literals)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

All contributors have agreed to the IPR Policy. Thank you!
Posted by the CLA Assistant Lite bot.

@torbenbrodt
Copy link
Author

I have read the IPR Policy

@torbenbrodt torbenbrodt force-pushed the fix/template-literal-syntax-error branch from d40866a to bf4ce83 Compare February 25, 2026 07:55
- Remove incorrect double backslash escaping in template literals
- Change ${index} to  in addPricingOption() and removePricingOption()
- Fixes 'Invalid or unexpected token' JavaScript error on add product page
@torbenbrodt torbenbrodt force-pushed the fix/template-literal-syntax-error branch from bf4ce83 to c02b301 Compare February 27, 2026 07:19
github-actions bot added a commit that referenced this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant