ExpressionEngine The template class analyzes curly braces {} as template variables , looks for three kinds of variables: single, pair, and conditional variables:
// Single Variable {summary} // Pair Variable {category} ... {/category} // Conditional Variable {if segment_2 != ""} ... {/if}
Curly braces in CSS are considered a special condition.
For example, the following CSS is acceptable for placement anywhere in the template and is parsed intelligently:
<style> p { margin-bottom: 1em; } p em { font-style: italic; } p.{site_name} { text-decoration: none; } {exp:channel:entries channel="channel_name" limit="1"} li.{url_title} a { color: #c00; } {/exp:channel:entries} </style>
Unfortunately, JavaScript is handled differently and does not allow the Advanced Conditionals Parser to process anything in tags. For example, the following JavaScript with curly braces all in one line :
<script>var addthis_config = { 'ui_click': true };</script>
ExpressionEngine will be parsed as a template variable and displayed as:
<script>var addthis_config = ;</script>
You will notice that everything from opening { and ending with a closing curly brace } is processed and replaced! As a workaround, you can put curly braces on separate lines and avoid this problem:
<script> var addthis_config = { 'ui_click': true, 'data_track_clickback': true }; </script>
If you wrote a JavaScript function that expects values from ExpressionEngine, just put your curly braces on separate lines - which is a good coding convention and is optimal for readability :
<script> $(document).ready(function() { ... {exp:channel:entries channel="channel_name" limit="1"} var business_name = '{business_website}'; var business_website = '{business_website}'; {/exp:channel:entries} ... }); </script>
As suggested by Ben, you can change this behavior by setting the Hidden configuration variable : $conf['protect_javascript'] = 'n';