Re: how to set a variable inside a page that uses a macro?
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Saturday, June 30, 2012, 7:32:13 PM, S Ahmed wrote:
> So I decided doing this in my macro with regards to injecting
> javascript from a page that uses the macro master.ftl:
>
> <#macro master javascript="" >
>
> <#nested>
>
> <script>
> $(javascript}
> </script>
>
> </#macro>
>
> Now my page looks like:
>
> <#import "/layout/master.ftl" as p>
> <@p.master>
>
>
> </@p.master>
>
> Now how can I create a javascript varialbe to pass to the master
> from within this page? Say I have this:
>
> <#import "/layout/master.ftl" as p>
> <@p.master>
>
> function sayHello() {
> alert("hello world " + "${user.name}");
> };
>
>
> </@p.master>
>
> How can I create a javascript variable and assign it to the javascript function I created?
I assume you want to specify something else between the @p.master
tags. Then:
<#import "/layout/master.ftl" as p>
<#assign js>
function sayHello() {
alert("hello world " + "${user.name}");
};
</#assign>
<@p.master js>
...
</@p.master>
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/