Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: What are your use-cases for the txp:yield tag?
Hi Sam,
thanks again.
Yes, your example is something I thought about but didn’t want to add it to my previous post, to make it shorter and as to see what you’ve got under the sleeves. :)
Also, you are right, named yields are somehow just a wrapper around the txp:variable, with the “advantage” of auto-scope/auto-destruction-after-usage/no-name-clashing, which make its easier to mentally grasp them.
Back to your example:
Surrounding the first block with a scope tag, though not required, will further ensure that no outer instances of these variables are overwritten.
This is where I get confused (and where I grapple/cling on the idea of named yields as an easier way), although I’ve to re-read again all the txp:scope info you already posted..
Edit: ok, Sam already replied the below questions (on his post above) while I was writing them.
Let me try to finish your example.
Is it this way?
<txp:output_form name="header">
<txp:scope local="true">
<txp:variable name="A">
Blah blah
Blah
</txp:variable>
<txp:variable name="B">
Blah
</txp:variable>
</txp:scope>
</txp:output_form>
Or this way?
<txp:scope local="true">
<txp:output_form name="header">
<txp:variable name="A">
Blah blah
Blah
</txp:variable>
<txp:variable name="B">
Blah
</txp:variable>
</txp:output_form>
</txp:scope>
Last edited by maniqui (2009-09-07 21:18:54)
Offline
Re: What are your use-cases for the txp:yield tag?
ruud wrote:
Why add
<txp:scope />to TXP core instead of releasing it as a plugin?
<txp:scope /> affects the behavior of <txp:variable /> and friends. Until plugins attain the ability to override core tags, the only way to implement <txp:scope /> as a plugin would be to also implement alternate plugin versions of <txp:variable />, <txp:if_variable />, etc. This in turn means changing a bunch of existing code in one’s pages and forms in order to add scoping. And then changing it back again later if <txp:scope /> were eventually added to core.
Offline
Re: What are your use-cases for the txp:yield tag?
Julián,
Your two examples are equivalent.
Offline
Re: What are your use-cases for the txp:yield tag?
artagesw wrote:
<txp:scope />affects the behavior of<txp:variable />and friends. Until plugins attain the ability to override core tags, the only way to implement<txp:scope />as a plugin would be to also implement alternate plugin versions of<txp:variable />,<txp:if_variable />, etc. This in turn means changing a bunch of existing code in one’s pages and forms in order to add scoping. And then changing it back again later if<txp:scope />were eventually added to core.
A good argument against having <txp:variable /> in core ;)
Offline
Re: What are your use-cases for the txp:yield tag?
ruud wrote:
A good argument against having
<txp:variable />in core ;)
I was going to make that very point. Your arguments apply equally to <txp:variable /> (itself a programmer-centric tag). Of course, <txp:variable /> is already in core and predates my joining the dev team…
Offline