smarty tries to read javascript

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

smarty tries to read javascript

Post 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.
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: smarty tries to read javascript

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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
Image
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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.
Image
Post Reply