You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/05/05 09:22:29 UTC

t5: embed a variable in a javascript in a tml?

Hi,

I'd like to get myid from the page,  but following code will not work, the
line:

var google_conversion_id = "${myid}"

will be rendered as it is, it is not as what I expected

var google_conversion_id = "12345678"

any idea how to embed a variable in a javascript in the template? thanks

Anelo


<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = ${myid}
var google_conversion_language = "en_US";
var google_conversion_format = "3";
var google_conversion_color = "ffffff"
//-->
</script>
-- 
View this message in context: http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23382334.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by Peter Stavrinides <P....@albourne.com>.
See this old thread: 
http://www.nabble.com/RenderSupport-addScript-old-browsers-td23039476.html

----- Original Message -----
From: "Peter Stavrinides" <P....@albourne.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Tuesday, 5 May, 2009 16:36:14 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: t5: embed a variable in a javascript in a tml?

>Why not just do:
><script language="JavaScript" type="text/javascript">
>var google_conversion_id = ${myid};

Are you being serious?

The html comment "<!--" is used supposedly to prevent scripts being read by browsers too old to understand them, though there are no browsers that old in operation any more. If you place your assignment outside the comment, why have the comment in the first place? Also consider the irony that HTML comments used in script blocks were included to prevent breaking older browsers, but including them in xhtml documents may just break the newest browsers or future browsers.

Peter 


-- 
If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Please visit http://www.albourne.com/email.html for important additional terms relating to this e-mail.

----- Original Message -----
From: "roubaozi" <la...@gmail.com>
To: users@tapestry.apache.org
Sent: Tuesday, 5 May, 2009 16:18:44 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: t5: embed a variable in a javascript in a tml?


Why not just do:
<script language="JavaScript" type="text/javascript">
var google_conversion_id = ${myid};
<!--
var google_conversion_language = "en_US";
var google_conversion_format = "3";
var google_conversion_color = "ffffff"
//-->
</script>



Angelo Chen wrote:
> 
> Hi,
> 
> I'd like to get myid from the page,  but following code will not work, the
> line:
> 
> var google_conversion_id = "${myid}"
> 
> will be rendered as it is, it is not as what I expected
> 
> var google_conversion_id = "12345678"
> 
> any idea how to embed a variable in a javascript in the template? thanks
> 
> Anelo
> 
> 
> <script language="JavaScript" type="text/javascript">
> <!--
> var google_conversion_id = ${myid}
> var google_conversion_language = "en_US";
> var google_conversion_format = "3";
> var google_conversion_color = "ffffff"
> //-->
> </script>
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23387274.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by Peter Stavrinides <P....@albourne.com>.
>Why not just do:
><script language="JavaScript" type="text/javascript">
>var google_conversion_id = ${myid};

Are you being serious?

The html comment "<!--" is used supposedly to prevent scripts being read by browsers too old to understand them, though there are no browsers that old in operation any more. If you place your assignment outside the comment, why have the comment in the first place? Also consider the irony that HTML comments used in script blocks were included to prevent breaking older browsers, but including them in xhtml documents may just break the newest browsers or future browsers.

Peter 


-- 
If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Please visit http://www.albourne.com/email.html for important additional terms relating to this e-mail.

----- Original Message -----
From: "roubaozi" <la...@gmail.com>
To: users@tapestry.apache.org
Sent: Tuesday, 5 May, 2009 16:18:44 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: t5: embed a variable in a javascript in a tml?


Why not just do:
<script language="JavaScript" type="text/javascript">
var google_conversion_id = ${myid};
<!--
var google_conversion_language = "en_US";
var google_conversion_format = "3";
var google_conversion_color = "ffffff"
//-->
</script>



Angelo Chen wrote:
> 
> Hi,
> 
> I'd like to get myid from the page,  but following code will not work, the
> line:
> 
> var google_conversion_id = "${myid}"
> 
> will be rendered as it is, it is not as what I expected
> 
> var google_conversion_id = "12345678"
> 
> any idea how to embed a variable in a javascript in the template? thanks
> 
> Anelo
> 
> 
> <script language="JavaScript" type="text/javascript">
> <!--
> var google_conversion_id = ${myid}
> var google_conversion_language = "en_US";
> var google_conversion_format = "3";
> var google_conversion_color = "ffffff"
> //-->
> </script>
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23387274.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by roubaozi <la...@gmail.com>.
Why not just do:
<script language="JavaScript" type="text/javascript">
var google_conversion_id = ${myid};
<!--
var google_conversion_language = "en_US";
var google_conversion_format = "3";
var google_conversion_color = "ffffff"
//-->
</script>



Angelo Chen wrote:
> 
> Hi,
> 
> I'd like to get myid from the page,  but following code will not work, the
> line:
> 
> var google_conversion_id = "${myid}"
> 
> will be rendered as it is, it is not as what I expected
> 
> var google_conversion_id = "12345678"
> 
> any idea how to embed a variable in a javascript in the template? thanks
> 
> Anelo
> 
> 
> <script language="JavaScript" type="text/javascript">
> <!--
> var google_conversion_id = ${myid}
> var google_conversion_language = "en_US";
> var google_conversion_format = "3";
> var google_conversion_color = "ffffff"
> //-->
> </script>
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23387274.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by Ville Virtanen <vi...@cerion.fi>.
Ofcourse one could write simple component that encapsulates the JS and
outputs required script tags and comment etc. things...

 - Ville


Ville Virtanen wrote:
> 
> The ugly way out of this is to output the comments using 
> 
> <t:outputraw value="commentStart">
> 
> and in java 
> 
> public String getCommentStart(){
>     return "<!--";
> }
> 
> and the same to the comment ending.
> 
> This also applies to different [CDATA etc. things.
> 
> If someone knows more elegant way please share...
> 
>  - Ville
> 
> 
> Felix Gonschorek wrote:
>> 
>> it does not work becaus the variable is in <!-- xxx --> html comments -
>> tapestry 
>> does not evaluate markup in html/xml comments.
>> 
>> felix
>> 
>> Kristian Marinkovic schrieb:
>>> never did this myself, but i think this should work somehow if there
>>> is a myid property...
>>> 
>>> instead... you could use the RenderSupport service to render your 
>>> script programmatically
>>> 
>>> g,
>>> kris
>>> 
>>> 
>>> 
>>> 
>>> Angelo Chen <an...@yahoo.com.hk> 
>>> 05.05.2009 09:22
>>> Bitte antworten an
>>> "Tapestry users" <us...@tapestry.apache.org>
>>> 
>>> 
>>> An
>>> users@tapestry.apache.org
>>> Kopie
>>> 
>>> Thema
>>> t5: embed a variable in a javascript in a tml?
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Hi,
>>> 
>>> I'd like to get myid from the page,  but following code will not work,
>>> the
>>> line:
>>> 
>>> var google_conversion_id = "${myid}"
>>> 
>>> will be rendered as it is, it is not as what I expected
>>> 
>>> var google_conversion_id = "12345678"
>>> 
>>> any idea how to embed a variable in a javascript in the template? thanks
>>> 
>>> Anelo
>>> 
>>> 
>>> <script language="JavaScript" type="text/javascript">
>>> <!--
>>> var google_conversion_id = ${myid}
>>> var google_conversion_language = "en_US";
>>> var google_conversion_format = "3";
>>> var google_conversion_color = "ffffff"
>>> //-->
>>> </script>
>> 
>> -- 
>> Felix Gonschorek
>> GG-Media
>> 
>> Kirchstr. 18
>> 69115 Heidelberg
>> 
>> Tel: +49 6221 890 168-0
>> Fax: +49 6221 890 168-1
>> Mobil: +49 176 2234 1338
>> 
>> felix@gg-media.biz
>> http://www.gg-media.biz
>> 
>> Vertretungsberechtigte Gesellschafter:
>> Felix Gonschorek & Jochen Greiner
>> 
>> Umsatzsteuer-Identifikationsnummer
>> gemäß § 27a Umsatzsteuergesetz:
>> DE232906440
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23387191.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by Ville Virtanen <vi...@cerion.fi>.
The ugly way out of this is to output the comments using 

<t:outputraw value="commentStart">

and in java 

public String getCommentStart(){
    return "<!--";
}

and the same to the comment ending.

This also applies to different [CDATA etc. things.

If someone knows more elegant way please share...

 - Ville


Felix Gonschorek wrote:
> 
> it does not work becaus the variable is in <!-- xxx --> html comments -
> tapestry 
> does not evaluate markup in html/xml comments.
> 
> felix
> 
> Kristian Marinkovic schrieb:
>> never did this myself, but i think this should work somehow if there
>> is a myid property...
>> 
>> instead... you could use the RenderSupport service to render your 
>> script programmatically
>> 
>> g,
>> kris
>> 
>> 
>> 
>> 
>> Angelo Chen <an...@yahoo.com.hk> 
>> 05.05.2009 09:22
>> Bitte antworten an
>> "Tapestry users" <us...@tapestry.apache.org>
>> 
>> 
>> An
>> users@tapestry.apache.org
>> Kopie
>> 
>> Thema
>> t5: embed a variable in a javascript in a tml?
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Hi,
>> 
>> I'd like to get myid from the page,  but following code will not work,
>> the
>> line:
>> 
>> var google_conversion_id = "${myid}"
>> 
>> will be rendered as it is, it is not as what I expected
>> 
>> var google_conversion_id = "12345678"
>> 
>> any idea how to embed a variable in a javascript in the template? thanks
>> 
>> Anelo
>> 
>> 
>> <script language="JavaScript" type="text/javascript">
>> <!--
>> var google_conversion_id = ${myid}
>> var google_conversion_language = "en_US";
>> var google_conversion_format = "3";
>> var google_conversion_color = "ffffff"
>> //-->
>> </script>
> 
> -- 
> Felix Gonschorek
> GG-Media
> 
> Kirchstr. 18
> 69115 Heidelberg
> 
> Tel: +49 6221 890 168-0
> Fax: +49 6221 890 168-1
> Mobil: +49 176 2234 1338
> 
> felix@gg-media.biz
> http://www.gg-media.biz
> 
> Vertretungsberechtigte Gesellschafter:
> Felix Gonschorek & Jochen Greiner
> 
> Umsatzsteuer-Identifikationsnummer
> gemäß § 27a Umsatzsteuergesetz:
> DE232906440
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23387164.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by Felix Gonschorek <fe...@gg-media.biz>.
it does not work becaus the variable is in <!-- xxx --> html comments - tapestry 
does not evaluate markup in html/xml comments.

felix

Kristian Marinkovic schrieb:
> never did this myself, but i think this should work somehow if there
> is a myid property...
> 
> instead... you could use the RenderSupport service to render your 
> script programmatically
> 
> g,
> kris
> 
> 
> 
> 
> Angelo Chen <an...@yahoo.com.hk> 
> 05.05.2009 09:22
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
> 
> 
> An
> users@tapestry.apache.org
> Kopie
> 
> Thema
> t5: embed a variable in a javascript in a tml?
> 
> 
> 
> 
> 
> 
> 
> 
> Hi,
> 
> I'd like to get myid from the page,  but following code will not work, the
> line:
> 
> var google_conversion_id = "${myid}"
> 
> will be rendered as it is, it is not as what I expected
> 
> var google_conversion_id = "12345678"
> 
> any idea how to embed a variable in a javascript in the template? thanks
> 
> Anelo
> 
> 
> <script language="JavaScript" type="text/javascript">
> <!--
> var google_conversion_id = ${myid}
> var google_conversion_language = "en_US";
> var google_conversion_format = "3";
> var google_conversion_color = "ffffff"
> //-->
> </script>

-- 
Felix Gonschorek
GG-Media

Kirchstr. 18
69115 Heidelberg

Tel: +49 6221 890 168-0
Fax: +49 6221 890 168-1
Mobil: +49 176 2234 1338

felix@gg-media.biz
http://www.gg-media.biz

Vertretungsberechtigte Gesellschafter:
Felix Gonschorek & Jochen Greiner

Umsatzsteuer-Identifikationsnummer
gemäß § 27a Umsatzsteuergesetz:
DE232906440

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: embed a variable in a javascript in a tml?

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
never did this myself, but i think this should work somehow if there
is a myid property...

instead... you could use the RenderSupport service to render your 
script programmatically

g,
kris




Angelo Chen <an...@yahoo.com.hk> 
05.05.2009 09:22
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
users@tapestry.apache.org
Kopie

Thema
t5: embed a variable in a javascript in a tml?








Hi,

I'd like to get myid from the page,  but following code will not work, the
line:

var google_conversion_id = "${myid}"

will be rendered as it is, it is not as what I expected

var google_conversion_id = "12345678"

any idea how to embed a variable in a javascript in the template? thanks

Anelo


<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = ${myid}
var google_conversion_language = "en_US";
var google_conversion_format = "3";
var google_conversion_color = "ffffff"
//-->
</script>
-- 
View this message in context: 
http://www.nabble.com/t5%3A-embed-a-variable-in-a-javascript-in-a-tml--tp23382334p23382334.html

Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org