Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2009-09-07 21:17:22

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#17 2009-09-07 21:29:36

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

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

#18 2009-09-07 21:31:28

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: What are your use-cases for the txp:yield tag?

Julián,

Your two examples are equivalent.

Offline

#19 2009-09-07 22:14:46

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#20 2009-09-07 23:01:05

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

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

Board footer

Powered by FluxBB