Page 1 of 1
smarty tries to read javascript
Posted: Thu Nov 24, 2005 11:21 am
by MySchizoBuddy
I have a javascript in my index.tpl file that looks like this
Code: Select all
<script type="text/javascript">
var exists;
var allStretch;
</script>
there is other stuff in it too.
and smarty is trying to parse it and giving me an error
syntax error: unrecognized tag 'var'
is it possible to stop smarty from parsing the javascript.
Re: smarty tries to read javascript
Posted: Thu Nov 24, 2005 11:58 am
by garvinhicking
Is that example code you gave really the example you are using? I don't know why smarty should parse that.
Have you replaced { and } with {rdelim} and {ldelim}?
Regards,
Garvin
Posted: Thu Nov 24, 2005 11:35 pm
by MySchizoBuddy
the actual code is this. It is
moo.fx effect library and the actual code which i copied from that website source code is
Code: Select all
<script type="text/javascript" src="scripts/prototype.lite.js"></script>
<script type="text/javascript" src="scripts/moo.fx.js"></script>
<script type="text/javascript" src="scripts/moo.fx.pack.js"></script>
<script type="text/javascript">
var exists;
var allStretch;
//the main function, call to the effect object
function init(){
var divs = document.getElementsByClassName("stretcher");
allStretch = new fx.MultiFadeSize(divs, {duration: 400});
items = document.getElementsByClassName("display");
for (i = 0; i < items.length; i++){
var h3 = items[i];
div = h3.nextSibling;
h3.title = h3.className.replace("display ", "");
if (window.location.href.indexOf(h3.title) < 0) {
allStretch.hide(div, 'height');
if (exists != true) exists = false;
}
else exists = true;
h3.onclick = function(){
allStretch.showThisHideOpen(this.nextSibling, 100, 'height');
}
}
if (exists == false) $('content').childNodes[1].fs.toggle('height');
}
</script>
so all the curly brackets need to be replaced
Posted: Fri Nov 25, 2005 12:00 am
by MySchizoBuddy
ok got it thanks garvin for the hints. i found this on smarty page:)
{literal} tags allow a block of data to be taken literally. This is typically used around javascript or stylesheet blocks where curly braces would interfere with the template delimiter syntax. Anything within {literal}{/literal} tags is not interpreted, but displayed as-is. If you need template tags embedded in your {literal} block, consider using {ldelim}{rdelim} to escape the individual delimiters instead.