TangibleInc / template-system

A template system for WordPress with content type loops and conditions
https://docs.loopsandlogic.com/reference/template-system/
6 stars 2 forks source link

`Format slug` incorrectly converting accented characters #118

Closed BenTangible closed 2 months ago

BenTangible commented 2 months ago

Commit a7af4a1 was added a few months ago to convert accented characters to non-accented ones when saving a template slug and when using <Format slug>. I'm pretty sure this worked when it was first released, but it was just reported on the forum that while this does still work for templates, the Format tag isn't properly converting things to slugs (e.g. é becoming %c3% instead of e).

eliot-akira commented 2 months ago

Ah, I see. I checked and <Format slug> is not using the function format\slugify() in the Framework, which was updated in that commit. This function is what's used to generate a post slug from title when a template is saved. So the commit solved #96, but the issue with accented characters remained with <Format slug>.

It was a simple fix (commit https://github.com/TangibleInc/template-system/commit/22cf7247ba33ef8c0d98580cf519d45f9c4d4965) but - looking over the code for the Format tag, in the folder language/format, I notice there's unfinished work where I'd started consolidating all the formatting functions into a general-purpose Format module in the Framework in framework/format.

I'll create an issue to track it:


Oh, in the Format tag function, I see there's an undocumented attribute count. It was added to count the number of items in a list, but also supports counting characters in a string (text).

Recently I was reading your exchange in the forum about creating an excerpt:

We keep coming back to this topic of custom excerpts, so I understand there's a need for a better way to do things. This <Format count> looks like it could help in that direction, for checking if a string needs to be trimmed.

<Format count>abcdefg</Format> = 7

Reminder to document this feature: