The description says it all. How to put a JavaScript script inside handlebars template.
I want to make a dynamic Paypal button for my website.
<script type="text/x-mustache-template" id="product-item-thumbnail-template"> <h2>{{title}}</h2> <p>{{message}}</p> <p><a class="btn" href="#">View details »</a></p> <p><script src="resources/js-frameworks/[email protected]" data-button="buynow" data-name="My product" data-amount="1.00"></script></p> </script>
But this produces an error because of the tag. it closes the template script and not the paypal script
Thanks
The Handlebars.js is a Javascript library used to create reusable webpage templates. The templates are combination of HTML, text, and expressions. The expressions are included in the html document and surrounded by double curly braces. These expressions are placeholders for content to be inserted by our Handlebars.
Handlebars is a simple templating language. It uses a template and an input object to generate HTML or other text formats. Handlebars templates look like regular text with embedded Handlebars expressions.
Handlebars: What it is and Why to Use itHandlebars is a logic-less templating engine that dynamically generates your HTML page. It's an extension of Mustache with a few additional features.
Mustache is missing helpers and the more advanced blocks because it strives to be logicless. Handlebars' custom helpers can be very useful, but often end up introducing logic into your templates. Mustache has many different compilers (JavaScript, Ruby, Python, C, etc.).
Try breaking up the "/script" part:
<script ...><{{!}}/script>
That technique is similar to older hacks like
<script>document.write("<script>...<\/script>");</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With