Re: Experiences with 2.14pre1
Felix Gnass <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
To answer one of my own questions ...
> 1) Is [#macro someMacro foo bar...={}] the correct syntax or do I have
> to write [@otherMacro bar=bar!{}] in line two?
In 2.4 "catch-all" parameters can't have a default value. You can either
write:
[#someMacro foo bar...]
[@otherMacro bar!{}]
[/#macro]
... or:
[#someMacro foo bar...]
[#if !bar??]
[#set bar = {}]
[/#if]
...
[/#macro]
... which might be more convenient if need to access the parameter more
than once.
In previous FreeMarker versions omitted "catch-all" parameter defaulted
to an empty sequence. I think this change should be mentioned in the
docs too.
-Felix
Felix Gnass wrote:
> Hi,
>
> I just tried to upgrade our codebase to 2.4pre1 and noticed the
> following things:
>
> Since the freemarker.core.ParseException moved to the
> freemarker.core.parser package, you can't use Spring's FreeMarkerView
> anymore, because I get a NoClassDefFound error. I copied the Spring
> sources and created my own FreeMarker24View (with a modified import
> statement) which works perfectly well.
>
> The second time I stumbled across the very same exception was when I
> tried to replace the freemarker.jar bundled with the Jboss Spring IDE
> Eclipse plug-in. Replacing the jar file used to work well with earlier
> releases, so I thought I'd give it a try.
>
> I haven't checked if this is the only API change that breaks backward
> compatibility with the plug-in, but in case it is (as it is with the
> Spring FreeMarkerView) it would be really helpful if the new
> freemarker.core.parser.ParseException would extend a deprecated
> freemarker.core.ParseException.
>
> The reason why I tried to replace the freemarker.jar in the first place,
> was that FreeMarker IDE reported a syntax error when I tried to specify
> a default value for a var-args parameter.
>
> My old macro that stopped working after the upgrade to 2.4 looks like this:
>
> [#macro someMacro foo bar...]
> [@otherMacro bar=bar]
> [/#macro]
>
> This code used to work, I think because "bar..." defaulted to an empty
> sequence (or hash?) in 2.3.
>
> I now get an error that "bar" is undefined when I try to pass it to the
> second macro in line 2. This makes sense, as no default is specified in
> the parameter list.
>
> I then tried to change the declaration to [#macro someMacro foo
> bar...={}] to check whether this is valid syntax in 2.4.
>
> This was the point where I got distracted, because my FreeMarker IDE
> told me that default values are not allowed for catch-all parameters. I
> assume the plug-in doesn't perform the parsing itself but delegates it
> to the bundled FreeMarker version, so replacing the freemarker.jar might
> actually work.
>
>
> To summarize my questions:
>
> 1) Is [#macro someMacro foo bar...={}] the correct syntax or do I have
> to write [@otherMacro bar=bar!{}] in line two?
>
> 2) Would you consider to re-introduce a deprecated ParseException in
> freemarker.core in case this solved the two problems outlined above?
>
>
> Kind regards,
> -Felix
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user