I'm working on a project using play framework 1.2.5
I have two custom tags files, one that does 'set' a value
#{set foo:'bar' /}
and another file that 'get' this value to make a decision to show some markup or not.
%{ if(foo) { %}
#{doBody /}
%{ } }%
This used to work in a previous play version (don't recall which) and now is not working, I'm not sure if it was the upgrade itself or something else got broken.
As per play documentations for template engine tags, set should work between different files:
Define a value which can be retrieved in the same template or any layout with the get tag. http://www.playframework.com/documentation/1.2.3/tags#set
Any clue on what might be wrong?
thanks in advance
set
only works with child template passing data to extended template, e.gparent template:
child template:
To pass data from one template to another template, you have to define the callee template as a tag. See play's document on more detail. Note I am not sure if tag could extend another tag, most probably it is not possible
If you are using PlayRythm plugin, then it is much easier. E.g. calling from template
foo
tobar
could be as easy asbar template:
foo template:
Note Rythm doesnot have a separate tag concept, literally every template is tag and you can call any template from another one or even do recursive call. You can try rythm's live interactive demo on http://fiddle.rythmengine.org/.
Disclaim: I am the creator and maintainer of Rythm template engine and Play-Rythm module