Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-07-14 15:30:27

Myusername
Member
Registered: 2019-12-12
Posts: 165

<txp:text/> and escape attribute

I’ve tried using the escape attribute on the <txp:text/> tag in every possible way, and it doesn’t seem to have any effect

<txp:text item="category"/> <!-- result: Category -->
<txp:text item="category" escape="lower"/> <!-- result: Category -->
<txp:text item="category" escape="upper"/> <!-- result: Category -->
<txp:text item="category" escape="quote"/> <!-- result: Category -->

I don’t see any syntax problems, and all of this produces the same result. Is this expected?

Tested on 4.8.7 and 4.9-dev.

Offline

#2 2021-07-16 15:42:44

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

Re: <txp:text/> and escape attribute

For the record, the tags that already had escape and other attributes before they have become global in 4.7 (?), continue to handle it themselves, for bw-compatibility reasons. In the case of <txp:text />, only html is accepted as escape value, and it concerns only the tag’s attributes, not its output:

<txp:text item='form_circular_reference' name="<b>test</b>" />

will result in

Too many nested form references while parsing form <strong>&lt;b&gt;test&lt;/b&gt;</strong>.

We could add other global escape values to <txp:text />, but is there a real use-case for it?

Offline

#3 2021-07-17 18:11:45

Myusername
Member
Registered: 2019-12-12
Posts: 165

Re: <txp:text/> and escape attribute

Honestly, I don’t think so.

I was just trying to do something like this (on a section page):

<txp:category_list break="li" wraptag="ul">
	<txp:category title="1" link="1"/>
</txp:category_list>

But the links resulted in /section/?c=hope-for-the-future. When in fact, I just wanted the link to /category/hope-for-the-future. So at the time I did the first thing that came to mind:

<site::url /><txp:text item="category"/>/<txp:category/>

However, the output of <txp:text item="category"/> is capitalized, which is not very nice for the URL, although it works anyway. So the escape attribute would solve this quickly, but to my surprise, it had no effect. So I thought it might be a bug and thought I’d better report it.

Anyway, I came back later in this part and realized I could do this:

<txp:category_list break="li" wraptag="ul" section="default">
	<txp:category title="1" link="1"/>
</txp:category_list>

Last edited by Myusername (2021-07-17 18:15:25)

Offline

#4 2021-07-19 12:54:49

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

Re: <txp:text/> and escape attribute

Done anyway, please test.

Offline

#5 2021-07-19 22:38:22

Myusername
Member
Registered: 2019-12-12
Posts: 165

Re: <txp:text/> and escape attribute

Yes, it works fine.

Last edited by Myusername (2021-07-19 22:38:51)

Offline

Board footer

Powered by FluxBB