Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2024-04-08 08:44:42

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

Re: Variable tweaks

phiw13 wrote #337049:

Is it? I see many failures (post above, variable="a€b"), but also, starting with a digit seem so work (sometimes?).

What is your code? This works for me:

<txp:variable name="a€b" value="abc" />
<txp:evaluate query="concat($a€b, 'a', $a€b)" alias="a€b" />

It is not for me to decide what is OK or not, and you certainly have a better view of what is possible, what the limits are and what you think you’ll be doing with all this in the future.

Nobody owns txp, we all just expose our reasons and make a decision. But we devs also have to care about (future) bwc issues, for our own mental sanity :-)

So from the start a good definition or description of allowed characters

Yep, alphanumeric means matching \w pattern (Latin Unicode letters, digits and _), sorry for not being clear here.

Edit: I have just extended ‘letter’ to unicode, since they are allowed in XPath variable names.

Offline

#32 2024-04-09 04:36:11

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,638
Website

Re: Variable tweaks

etc wrote #337050:

What is your code? This works for me:

<txp:variable name="a€b" value="abc" />…

Yours works without problems, directly in an article or inserted in a form then loaded in the page template.

The code block I have been playing with is your original sample, changing the name of the variable, using currency symbols and other Unicode characters

<txp:date format="%m" escape="integer" variable="abcd" />
<txp:evaluate query="$abcd >= 4 and $abcd <= 8" alias="abcd">
Some lovely weather wraps around weeks of heavy rains
</txp:evaluate>

Yep, alphanumeric means matching \w pattern (Latin Unicode letters, digits and _), sorry for not being clear here.

Edit: I have just extended ‘letter’ to unicode, since they are allowed in XPath variable names.

For some reason this makes reason this makes my test work better I think. Unicode characters do make sense, I don’t expect someone to name the variable with CJK / Hindi / Arabic … characters, but some extended Latin or Roman ”looking” characters – I was just thinking about the Turkish dotless ‘i‘ (ı U+0131) for an unrelated reason – might easily creep in (Turkic languages, Vietnamese, transliteration of CJK, etc).

For documentation purposes, there is still a need for mentioning that the closing character must be one of “end with a-zA-Z0-9_ (to match \b regex pattern)” as you noted above. (Sorry about insisting about this, but given that Xpatch can be a little picky, it is better to have it documented well from the start.)


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

Offline

Board footer

Powered by FluxBB