Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2019-11-21 10:22:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,842
Website

Re: Ranges

Good find, Pete. I actually quite like the square-bracket notation, even though it is up to three extra chars.

12, 14, 5, [42, 48], 73, [-1,-6]

Encapsulated, and permits an optional space after the comma as well, if you have the capacity in your field to use it (although the lack of space does make it more visually distinct). Plus it’s fairly easy to parse.

Is it intuitive enough? Thoughts?

Last edited by Bloke (2019-11-21 10:26:20)


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

#12 2019-11-21 10:23:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,842
Website

Re: Ranges

gaekwad wrote #320172:

I must be half asleep. Did you sneak in a ninja edit or did I miss that last sentence?

Hehe, no ninja edit (for a change!)

Köffee? :)


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

#13 2019-11-21 10:26:10

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: Ranges

+1 for square brackets, but I’m not in a position to know where negative ranges would be used on my fleet, so it’s a heavy pencil +1. Looks clean, too.

Offline

#14 2019-11-21 10:28:12

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: Ranges

Bloke wrote #320174:

Köffee? :)

I’m a bit light on sleep in recent days, it must be said. I don’t think the chocolate-covered coffee beans I munched a few minutes ago were the smartest idea, but they’re getting the job done!

Offline

#15 2019-11-21 11:44:04

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 1,761
Website

Re: Ranges

Bloke wrote #320168:

Just playing devil’s advocate here, but have we got any concrete use cases in mind where we, or someone using Textpattern, might legitimately use ranges with negative numbers?

Interesting question (more from a theoretical POV), because I don’t think it would be frequent in everyday usage. Hmm, maybe as the result of a <txp:evaluate /> calculation? I don’t know, just thinking aloud.

I kinda like the [ ] suggestion that came later in the thread. Still quite readable and understandable.

Last edited by phiw13 (2019-11-21 11:44:40)

Offline

#16 2019-11-21 11:59:55

etc
Developer
Registered: 2010-11-11
Posts: 3,427
Website

Re: Ranges

gaekwad wrote #320169:

Out of curiosity: what’s a real-world example of a negative range in Textpattern terms? Bullet point is fine, I’m clearly missing something obvious.

Negative values are rare animals in txp word, but do exist. For example, shift attribute of <txp:older /> can be a range of negative values:

<txp:older link shift="-3,-2,-1">
    Page <txp:yield item="page" />
</txp:older>

will output three oldest pages (4.8 only). But I agree, that’s an exotic usage and large negative ranges are unlikely to be ever needed. So we could stay with the standard 1-9 notation and add -9- -1-ish patterns parsing as Stef suggests just in case.

Offline

Board footer

Powered by FluxBB