Re: setting variables from within a custom TemplateDirectiveModel

Grégory Joseph <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
On Feb 26, 2010, at 22:20, Daniel Dekany wrote:

> Friday, February 26, 2010, 8:47:04 PM, Grégory Joseph wrote:
> 
>> Hi,
>> 
>> I have a TemplateDirectiveModel which renders its body - pretty straightforward.
>> 
>>            body.render(env.getOut());
>> 
>> Now, what I'd need is to push variables to be used by this body.
>> I've tried the following, before calling body.render:
>>            //env.setLocalVariable("myVar", new SimpleScalar("local!"));
>>            env.setVariable("myVar", new SimpleScalar("regular!"));
>>            env.setGlobalVariable("myVar", new SimpleScalar("global!"));
>> 
>> .. to no avail.
> 
> What exactly was the problem with env.setVariable (and
> setGlobalVariable)?

--- please disregard the e-mail i sent just before. Must have been friday, cause I see it working now, at least in the case it can work (I had another case where it can't, because the Environment isn't shared...)

> 
>> Am I missing something, or is there something else
>> I should be looking at ? I'm not too keen on using loopVars, because
>> in this case, the user of my directive shouldn't even know about the
>> variable i'm trying to push - and here comes my use case: I need to
>> share some information from this directive to other (custom)
>> directives which are being used in the body of the former.
>> 
>> Any idea or suggestion ?
>> 
>> Cheers,
>> 
>> -greg
>> 
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> FreeMarker-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>> 
> 
> -- 
> Best regards,
> Daniel Dekany
> 



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.