Discussion:
[FreeMarker-user] Is it possible to assign multiple macro calls into an array
Albert Kam
2015-02-13 09:44:25 UTC
Permalink
Hello !

I know this is absurd example, but instead of doing these repetitive row
macro calls on each comment :
<@commentbox>
<@row>
<@comment id=1 />
</@row>
<@row>
<@comment id=2 />
</@row>
<@row>
<@comment id=1 />
</@row>
</@commentbox>

It'll be simpler if i could do something like this :
<@commentbox>
<#assign comments=[
<@comment id=1 />,
<@comment id=2 />,
<@comment id=1 />
]>
<@wrapInRow comments />
</@commentbox>

I know we can nest macro result within the assign tag, but it doesnt solve
the repetitiveness of the assign tag calls.

Is this supported or planned ? Or perhaps there's a pattern for this
situation ?

Thank you !
--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)
Daniel Dekany
2015-02-13 19:37:47 UTC
Permalink
Post by Albert Kam
Hello !
I know this is absurd example, but instead of doing these
<#assign comments=[
]>
I know we can nest macro result within the assign tag, but it
doesnt solve the repetitiveness of the assign tag calls.
Is this supported or planned ? Or perhaps there's a pattern for this situation ?
Not sure what input the @comment macros has in reality... it it were
only an ID-s, then this comes to my mind:

<@wrapInRow comment 1 2 1 />

So here the trick is that you pass in the macro itself, and then the
argument for each macro call.

As of collecting macro calls in a list (actually, in a tree), then
calling them later... that's a tricky topic. Something similar is in
fact planned (mostly focusing on layout problems though), after some
other major developments, so it's very, very far away, given the pace
of development here.
Post by Albert Kam
Thank you !
--
Thanks,
Daniel Dekany
Albert Kam
2015-02-14 12:10:43 UTC
Permalink
Ah, great idea. I could pass hashes as the arguments for more complex
parameters.

Thanks !
Post by Albert Kam
Post by Albert Kam
Hello !
I know this is absurd example, but instead of doing these
<#assign comments=[
]>
I know we can nest macro result within the assign tag, but it
doesnt solve the repetitiveness of the assign tag calls.
Is this supported or planned ? Or perhaps there's a pattern for this
situation ?
So here the trick is that you pass in the macro itself, and then the
argument for each macro call.
As of collecting macro calls in a list (actually, in a tree), then
calling them later... that's a tricky topic. Something similar is in
fact planned (mostly focusing on layout problems though), after some
other major developments, so it's very, very far away, given the pace
of development here.
Post by Albert Kam
Thank you !
--
Thanks,
Daniel Dekany
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is
your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)
Continue reading on narkive:
Loading...