[Helma-user] some observations with nested macros
Hannes Wallnoefer
hannes at helma.at
Tue Apr 24 16:24:57 CEST 2007
Hi Tobi,
2007/4/24, tobias.schaefer at orf.at <tobias.schaefer at orf.at>:
> hi there
>
> made some observations with nested macros; maybe someone could explain:
>
> 1. why do i get the macro error?
>
> var s = createSkin('<% param.foo default=<% param.bar %> %>');
> renderSkin(s, {foo: 1, bar: 2});
> => 1
> renderSkin(s, {foo: null, bar: 2});
> => [Macro error in param.foo: java.lang.Integer]
It's a bug, Helma is expecting a String here. Will be fixed.
> 2. why isn't "bar" titleized, but "foo" is always?
>
> var s = createSkin('<% param.foo | titleize %>');
> renderSkin(s, {foo: "foo", bar: "bar"});
> => Foo
> var s = createSkin('<% param.foo default=<% param.bar %> | titleize %>');
> renderSkin(s, {foo: null, bar: "bar"});
> => bar
> // even worse:
> var s = createSkin('<% param.foo prefix=<% param.bar %> | titleize %>');
> renderSkin(s, {foo: "foo", bar: "bar"});
> => barFoo
>
> (i think the filter should be applied after prefix / default have been applied.)
I don't think that filters should be applied after prefix/default have
been applied. In most cases, when you supply a default value as
string, you'll put it there as it should be displayed. Same with
prefix and suffix. And to apply prefix/suffix/default, the macro
output has to be converted to a string. So all filters operating on
other objects would stop working with prefix/suffix:
<% date prefix="Date: " | format %>
What could work is to make the default macro inherit the filter chain
of the containing macro, but I'm not really sure about the
implications. As a solution, you should be able to add your own filter
chain to the default macro.
hannes
> ciao,
> tobi
> _______________________________________________
> Helma-user mailing list
> Helma-user at helma.org
> http://helma.org/mailman/listinfo/helma-user
>
More information about the Helma-user
mailing list