Re: ".vars" names can't contain dashes?

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, June 10, 2011, 7:00:10 PM, Rodney Gitzel wrote:

> There's no Freemarker configuration to speak of.   Freemarker is
> running inside a Struts 2 app, which has configuration for *finding*
> templates but not for processing them.   Well, except maybe for
> "struts.freemarker.wrapper.altMap" which didn't seem to matter (I
> tried both false and true values).
>
> The template is dead simple: I emptied out an existing working
> template and put in just the .vars expressions on their own, so
> there shouldn't be any other macros or variables or such coming into play.
>
> The data structure isn't anything special:  we put plain old Java
> ResourceBundles onto the value stack by name (e.g. 
> "resources_product" where "product" could be any product code).  
> .vars picks them out of there no problem normally.
>
> Later today I may try to reproduce it outside of Struts.   Also, I
> could trace it with the debugger, but when trying to trace the
> exceptions thrown yesterday, it wasn't clear at all what classes
> were doing what.  Is there an obvious place to put a breakpoint for .vars processing?

freemarker/core/BuiltinVariable.java line 192 where it's implemented.
But it's just a env.getVariable(key) call, leads to
freemarker/core/Environment.java line 1068. So I have no idea what
could cause the problem. My only guess remains that the it's the root
hash that returns those odd values.

> Thanks!
>
> rodney
>
> On Thu, Jun 9, 2011 at 5:17 PM, Daniel Dekany <[email protected]> wrote:
> Friday, June 10, 2011, 1:12:10 AM, Rodney Gitzel wrote:
>
>> We're using version 2.3.16, and I've just tracked down a weird bug
>> in one of our apps.  It came down to there now being hyphens in some
>> of our product code strings.  The codes are used to pull hashes of
>> localized text from the global scope using ".vars".   Upgrading to
>> 2.3.18 did not change the issue I found.
>>
>> Reducing the issue brought me to an example that anyone can try: 
>> ${.vars["foo-bar"]}  in a template outputs "0" (without the quotes).
>> ${.vars["foo+bar"]} outputs "nullnull".   ${.vars["foobar"]}
>> correctly triggers an InvalidReferenceException.   All three should fail, not just the last one.
>>
>> http://freemarker.sourceforge.net/docs/app_faq.html#faq_strange_variable_nameimplies
>> this should work.   Instead, it appears the ".vars" parameter string is being evaluated!   
>
>
> It works correctly here. What are your configuration settings (not
> like I have any idea now how to achieve this with settings...)? Or is
> your data-model something special?
>
>> I saw mention of a similar issue a few weeks ago on this mailing
>> list, and it was suggested to prefix the parameter string with "@". 
>> That might work with other hashes, but it does NOT work with
>> ".vars".
>
> That has nothing to do with these. That was an XML thing, where the
> name of the variable was indeed @something.
>
>> I just took a working example (.vars["resources_title"]) and that
>> change made it throw an InvalidReferenceException
>> (.vars["@resources_title"]).
>>
>> Thanks.
>>
>> rodney
>>
>>
>
> --
> Best regards,
>  Daniel Dekany
>

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
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.