Nested blocks and place holder

1 view
Skip to first unread message

michaelCH

unread,
Mar 31, 2009, 9:10:27 AM3/31/09
to rife-users
Hello Geert!

I would like to describe my problem with nested blocks and value
holders.

When I have such a iteration of items:

for(item: itemList) {
for(tag: tagList) {
template.setValue("v1", "text1");
template.appendBlock("b1", block1");
}
template.setBlock("b2", "block2");
}

Value holder b1 and are inside block2 in the template.
In my case the problem is that block1 appears in all items in not only
in one item as i would excpect. I thought that template.setBlock
("b2", "block2") "close" the place holder "b1" and next taglist will
not have taglist from previous item. It mean the place holder is
"global" for the template in case we use nested blocks ?

It would be very helpful if you could suggest another solution for it.
I guess it typicall issue when you start to use nested blocks.

Best regards,
Michael Chudas.

Geert Bevin

unread,
Mar 31, 2009, 12:31:16 PM3/31/09
to rife-...@googlegroups.com
This is done on purpose so that you can have blocks fill in value
placeholders at several locations in your template. Everything is
global in a RIFE template, there's no scoping of values within blocks.
To do this iteration, you simply clear the v1 value in the beginning
of the second for loop with for instance template.blankValue("v1")

HTH,

Geert

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Flytecase Band - http://flytecase.be
Music and words - http://gbevin.com

Reply all
Reply to author
Forward
0 new messages