This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:using_javascript_in_smarty_templates:start [2010/04/30 19:51] matt created |
tutorials:using_javascript_in_smarty_templates:start [2014/09/25 16:55] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
=====Using JavaScript inside SMARTY Templates===== | =====Using JavaScript inside SMARTY Templates===== | ||
+ | |||
+ | <tip c n> | ||
On occasion, it may be appropriate to add a block of JavaScript code to one of your template files. One of the most common uses of this is when adding Google Analytics to a site. There is one important caveat to be aware of: both JavaScript and SMARTY have different interpretations of the left-curly-brace character **' | On occasion, it may be appropriate to add a block of JavaScript code to one of your template files. One of the most common uses of this is when adding Google Analytics to a site. There is one important caveat to be aware of: both JavaScript and SMARTY have different interpretations of the left-curly-brace character **' | ||
- | There are a couple of ways around this. You can either replace all of the left-curly-braces in your Javascript with the {ldelim} tag, or you can simply wrap the entire javascript code in {literal}{/ | + | There are a couple of ways around this. You can either replace all of the left-curly-braces in your Javascript with the {ldelim} tag, or you can simply wrap the entire javascript code in **{literal}{/ |
+ | |||
+ | <tip c n> | ||
We'll show the oft-offending piece of Google Analytics code here, by way of example. Google generally supplies the code like this: | We'll show the oft-offending piece of Google Analytics code here, by way of example. Google generally supplies the code like this: |