Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-09-24 13:27:48

etc
Developer
Registered: 2010-11-11
Posts: 5,132
Website GitHub

Self-closed form of <txp:if_...> tags

I sometimes use if_variable tag as 0/1 flag:

<txp:section link='<txp:if_variable name="link" value="yes">1<txp:else />0</txp:if_variable>' />

I suggest that we allow if_variable (and other if_ tags) be self-closed, so <txp:if_variable name="link" value="yes" /> returns 1 or 0. We could then write just

<txp:section link='<txp:if_variable name="link" value="yes" />' />

Offline

#2 2016-09-24 15:09:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,064
Website GitHub Mastodon Twitter

Re: Self-closed form of <txp:if_...> tags

etc wrote #301728:

I sometimes use if_variable tag as 0/1 flag:

<txp:section link='<txp:if_variable name="link" value="yes">1<txp:else />0</txp:if_variable>' />...

I suggest that we allow if_variable (and other if_ tags) be self-closed, so <txp:if_variable name="link" value="yes" /> returns 1 or 0. We could then write just

<txp:section link='<txp:if_variable name="link" value="yes" />' />...

Looks logical to me.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2016-10-24 21:45:47

etc
Developer
Registered: 2010-11-11
Posts: 5,132
Website GitHub

Re: Self-closed form of <txp:if_...> tags

Done, under Yiannis responsibility :-)

Offline

#4 2016-10-25 01:52:41

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Self-closed form of <txp:if_...> tags

+1 – I think this will be very handy

Offline

#5 2016-10-26 05:50:53

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,138
Website

Re: Self-closed form of <txp:if_...> tags

@etc,

Did you cause this little weirdness with that commit?


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#6 2016-10-26 08:09:01

etc
Developer
Registered: 2010-11-11
Posts: 5,132
Website GitHub

Re: Self-closed form of <txp:if_...> tags

phiw13 wrote #302495:

@etc,

Did you cause this little weirdness with that commit?

Yeah, did it again :-( if_plugin was affected too, now should be fixed, thanks!

Offline

#7 2016-10-26 08:33:28

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,138
Website

Re: Self-closed form of <txp:if_...> tags

etc wrote #302497:

Yeah, did it again :-( if_plugin was affected too, now should be fixed, thanks!

Oups :-) Now works as expected.

I still need to wrap my around what new goodies those self closing <txp:_if… /> will bring to the table.
if you have time, a (long winded…) blogpost or so would be appreciated !


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#8 2016-10-26 10:19:19

etc
Developer
Registered: 2010-11-11
Posts: 5,132
Website GitHub

Re: Self-closed form of <txp:if_...> tags

phiw13 wrote #302499:

I still need to wrap my around what new goodies those self closing <txp:_if… /> will bring to the table.
if you have time, a (long winded…) blogpost or so would be appreciated !

It’s just an easier-to-parse shortcut for <txp:if_tag>1</txp:if_tag>. For example

<txp:comments_invite textonly='<txp:if_comments_disallowed />' />

looks (and parses) better than

<txp:comments_invite textonly='<txp:if_comments_disallowed>1</txp:if_comments_disallowed>' />

And when we’ll have a universal core txp:not (say) attribute, this will be possible too:

<txp:section_list wraptag="ul" break="li">
    <txp:section title="1" link='<txp:if_section txp:not name=''<txp:section />'' />' />
</txp:section_list>

Offline

Board footer

Powered by FluxBB