Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2017-12-15 13:45:48

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

Re: Poll: useful 'escape' transforms

etc wrote #308314:

Dunno what to do with this, prepend a space, perhaps?

<txp:evaluate escape="textile" wraptag="figcaption"> <txp:image_info type="caption" /></txp:evaluate>…

Winner! <txp:evaluate /> is truly magic.

No, <txp:evaluate query='ceiling(2.718 div 1.618)' /> is fine.

Great, thanks. I’ll play with that.


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

Offline

#26 2017-12-15 14:48:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Poll: useful 'escape' transforms

phiw13 wrote #308315:

Winner! <txp:evaluate /> is truly magic.

Seconded!


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

Online

#27 2017-12-15 15:13:54

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Poll: useful 'escape' transforms

I think the evaluate tag doc probably needs to be fleshed out a bit further. Doesn’t seem to capture how useful this tag is right now (and I don’t fully understand the tag myself so I can’t write about it).

Offline

#28 2017-12-17 16:11:05

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

Re: Poll: useful 'escape' transforms

etc wrote #308314:

Dunno what to do with this, prepend a space, perhaps?

<txp:evaluate escape="textile" wraptag="figcaption"> <txp:image_info type="caption" /></txp:evaluate>

Another possibility is to consider any undocumented escape value xyz as “unwrap <xyz /> tag”. Then the example above would become

<txp:image_info type="caption" escape="textile, p" wraptag="figcaption" />

A working commit is ready, I’m just not sure whether this is not too confusing.

Edit: BTW, escape="img" would mean “remove images” (from Textile-formatted text), which could be handy in excerpts.

Offline

#29 2017-12-17 22:48:27

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

Re: Poll: useful 'escape' transforms

etc wrote #308318:

Another possibility is to consider any undocumented escape value xyz as “unwrap <xyz /> tag”.

… I’m just not sure whether this is not too confusing.

That is certainly interesting, and powerful. Confusing? Just a little, at first sight.

(I find myself increasingly in need to document my code snippets. The other day I was looking at some category related snippet that I coded some month ago. I had to read it over a few times before understanding what I intended to do).


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

Offline

#30 2017-12-18 09:14:51

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

Re: Poll: useful 'escape' transforms

Bloke wrote #308299:

Possibly some way to remove newlines but preserve spaces? Is that helpful, as distinct from trim?

Yes, I think, e.g. for “inline” Textile. I have added implode value (the name to debate) that preg-replaces \s+ with a space and also prepends a space. So,

*This* is

a _test_

becomes first (space)*This* is a _test_ and then <strong>This</strong> is a <em>test</em> when passed through escape="implode, textile".

Offline

#31 2017-12-18 10:06:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Poll: useful 'escape' transforms

etc wrote #308320:

I think, e.g. for “inline” Textile. I have added implode value (the name to debate)

Nice, that’ll be handy. I made a note on the commit about the name of the transform before I saw this post. You’re right, we need to think of something less geeky for it. No inspiration right now, sorry.


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

Online

#32 2017-12-18 12:01:50

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

Re: Poll: useful 'escape' transforms

Bloke wrote #308321:

we need to think of something less geeky for it.

That’s also the purpose of this thread, including other values too. Is excerpt="tags" less geeky than excerpt="strip" for strip_tags()? I’d better finish it now, not sure to have an internet connection the next week.

Offline

#33 2017-12-18 12:09:18

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

Re: Poll: useful 'escape' transforms

etc wrote #308322:

That’s also the purpose of this thread, including other values too. Is excerpt="tags" less geeky than excerpt="strip" for strip_tags()?

You mean escape, right? But probably yes, escape=tags is less programmer lingo. implode … hold on I need to consult my dictionaries here ;-)


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

Offline

#34 2017-12-18 12:20:15

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

Re: Poll: useful 'escape' transforms

phiw13 wrote #308323:

You mean escape, right? But probably yes, escape=tags is less programmer lingo. implode … hold on I need to consult my dictionaries here ;-)

Right. :-) So, let it be tags. And join for implode(), perhaps? Or gather, or any of these?

Offline

#35 2017-12-18 13:42:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Poll: useful 'escape' transforms

etc wrote #308318:

Another possibility is to consider any undocumented escape value xyz as “unwrap <xyz /> tag”.

That has merit. I don’t think it’s confusing insofar as we’ve already introduced a “processing chain” in the escape attribute, so the stuff is processed in order of value anyway. Thus being able to strip specific tags from the content (in addition to being able to do the global ‘strip all’) – before or after some other built-in transforms – would be remarkably powerful.

Just bear in mind that I think we’ve sometimes advocated escape="raw" in place of escape="" (though I can’t find an example of course!) which would try to remove any <raw /> tags under the proposed patch.

How about: escape=...

  • tags for strip_tags().
  • integer for intval().
  • spaces for this particular implementation of implode().

?

In that last one, we’re not exactly ‘escaping’ spaces but we are gobbling them up. Dunno.


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

Online

#36 2017-12-18 14:08:47

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

Re: Poll: useful 'escape' transforms

Don’t think raw or <raw /> is used anywhere, so nothing bad should happen. Note that only self-closed tags are removed, <p>content</p> will be unwrapped as content. Well, it’s already committed, so the time will see. :-)

I’m fine with tags and integer, not sure for spaces. The most noticeable effect of this transform is removing the line breaks and indenting, to prevent Textile from wrapping the string in <p />. We could even drop it, in favor of unwrapping <p /> with escape="p", but this yields more processing.

Offline

Board footer

Powered by FluxBB