Templates: Variable expansion in inline JS ?

147 views
Skip to first unread message

Roberto Saccon

unread,
Nov 24, 2009, 10:45:35 PM11/24/09
to nitro-devel
While everything works fine within HTML templates, if I have JS
inlined, and try there to use variables, they don't get expanded.

Is there a way to handle this ?

--
Roberto

George Moschovitis

unread,
Nov 25, 2009, 2:59:11 AM11/25/09
to nitro...@googlegroups.com
I don't understand what you mean, can you present an example?

-g.


--

You received this message because you are subscribed to the Google Groups "nitro-devel" group.
To post to this group, send email to nitro...@googlegroups.com.
To unsubscribe from this group, send email to nitro-devel...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nitro-devel?hl=en.





--
blog.gmosx.com

Roberto Saccon

unread,
Nov 25, 2009, 7:26:40 AM11/25/09
to nitro-devel
Here is the example I run into that issue. I took a demo from a mobile
JS kit and had to slightly adapted it by introducing a {site} variable
to make it work with my multi-site nitro middleware (work-in-
progress). But probably because of the {} nature of Javascript,
{domain} got not expanded, when it is in such inline JS.

<!doctype html>
<html>
<head>
....
....
<script type="text/javascript" charset="utf-8">
var jQT = new $.jQTouch();
$(function(){
jQT.gallery_init({
toggleToolbars: 5000,
gallery: 'baseball',
title: 'Baseball',
media: [
{ image: "img/{site}/mobile/baseball_ball.jpg", caption:
'Ball' },
{ image: "img/{site}m/mobile/baseball_field.jpg", caption:
'Field' },
{ youtube: "KdfOGmMZKro", caption: 'MLB 09: The Show' }
]
});
});
</script>
</head>
.....
.....



On Nov 25, 4:59 am, George Moschovitis <george-moschovi...@gmosx.com>
wrote:
> I don't understand what you mean, can you present an example?
>
> -g.
>
>
>
>
>
> On Wed, Nov 25, 2009 at 5:45 AM, Roberto Saccon <rsac...@gmail.com> wrote:
> > While everything works fine within HTML templates, if I have JS
> > inlined, and try there to use variables, they don't get expanded.
>
> > Is there a way to handle this ?
>
> > --
> > Roberto
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "nitro-devel" group.
> > To post to this group, send email to nitro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nitro-devel...@googlegroups.com<nitro-devel%2Bunsubscribe@googlegr oups.com>
> > .

George Moschovitis

unread,
Nov 25, 2009, 1:19:41 PM11/25/09
to nitro...@googlegroups.com
I thought that should work, I haven't seen such a problem in practice.

Perhaps you can try this:

var site = "{site}";
...

image: "img/" + site + "/m....

until I find the time to have a look at this...

-g.


To unsubscribe from this group, send email to nitro-devel...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nitro-devel?hl=en.


Roberto Saccon

unread,
Nov 25, 2009, 5:36:52 PM11/25/09
to nitro-devel
George, thanks, with that trick it works.

--
Roberto

On Nov 25, 3:19 pm, George Moschovitis <george-moschovi...@gmosx.com>
wrote:
Reply all
Reply to author
Forward
0 new messages