Re: some observations with nested macros
"Hannes Wallnoefer" <[email protected]>
| Newsgroups | gmane.comp.java.helma.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Tobi, 2007/4/24, [email protected] <[email protected]>: > 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 > [email protected] > http://helma.org/mailman/listinfo/helma-user >