Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Cannot get escaping "tidy, textile" working
<txp:body escape="tidy, textile"/>
Should give me the content of the body field without the surrounding <p>, correct?
In my case it seems not to work at all and I still get surrounding <p> and I am wondering why.
This works fine though:
<txp:body escape="tidy, p"/>
Offline
Re: Cannot get escaping "tidy, textile" working
demoncleaner wrote #331650:
<txp:body escape="tidy, textile"/>...
Should give me the content of the body field without the surrounding <p>, correct?
No, it should textile
the output of <txp:body />
(without wrapping it with <p>
) after some whitespace normalization (tidy
). But <txp:body />
output is already textiled, so escape
has no effect here.
Offline
Re: Cannot get escaping "tidy, textile" working
OK. Thanks, I almost understand.
But shouldn´t
<txp:variable name="test" value='<txp:body/>' escape="tidy, textile" output/>
work than?
But that gives me still surounding <p>.
What am I missing?
Or let me ask in a different way:
What would I have to do when I want the contents of the body field output without any surounding <p>.
(Changing the format in the backend cannot be an option unfortunately.)
Last edited by demoncleaner (2021-09-23 13:01:44)
Offline
Re: Cannot get escaping "tidy, textile" working
The Body field (and Excerpt) already has Textile applied, and already has the surrounding ‘p’ tags.
Telling escape
to tidy it (remove newlines and add a preceding space) and then pass it through Textile is a waste of time, since it’s already been passed through Textile. The <txp:body>
tag actually outputs the Body_html
field (at least, if it doesn’t, it should!). It applies Textile on save, not on output, for performance reasons. Additionally, you might get odd results if it encounters something in the HTML that it doesn’t quite understand.
In your <txp:variable>
example, the same applies. You’re populating the variable with HTML from the article body, and then asking the variable to pass its content through Textile. That’ll have no effect.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Cannot get escaping "tidy, textile" working
demoncleaner wrote #331655:
What would I have to do when I want the contents of the body field output without any surounding <p>.
<txp:custom_field name="body" escape="tidy, textile" />
:)
(though that’ll have a performance impact on your pages as it re-Textile’s the entire article on the fly)
Last edited by Bloke (2021-09-23 14:13:38)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Cannot get escaping "tidy, textile" working
OK. I see =). Thank you.
Maybe then that´s a bit misleading here for somebody that has no clue how exactly it works in the background.
https://docs.textpattern.com/tags/learning/#available-escape-values
Remove spaces/newlines, prepend a single space to remove the surrounding <p> tag, then Textile the content.
I thought I can use it in a situation where I just use the body field for just one sentence or so and do not want it to be wrapped in <p>. Get rid of it and textile it again.
Of course changing the format in the backend is an option as well. But I normally try to avoid it because this can easily be overseen by somebody who is not so much into textpattern.
At least I know now why it is not working. Think I change my idea of how to use the body field in those cases and better make use of a custom_field. Thanks again!
Last edited by demoncleaner (2021-09-23 15:10:53)
Offline
Re: Cannot get escaping "tidy, textile" working
demoncleaner wrote #331658:
Maybe then that´s a bit misleading here for somebody that has no clue how exactly it works in the background.
The docs are a bit long, but they do state that
global attributes cannot intervene in a tag’s internal processing and are applied only to the tag’s output.
So, when the global escape="textile"
is applied to <txp:body />
, it is too late, it will just be textiled a second time.
Offline
Re: Cannot get escaping "tidy, textile" working
OK. Got it. So as far as I can see then in my scenario escape="tidy, p"
or better just using a custom_field instead of body would be the weapon of choice. Thanks guys.
Offline