This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorials:using_javascript_in_smarty_templates:start [2010/08/11 19:01] jonyo tip thingy for google analytics |
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 **' | ||
Line 5: | Line 7: | ||
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> | + | <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: |