The issue seems random, and I am unsure how to recreate it without manually inserting an em dash, but it may have something to do with the use of em dashes in the Templates list.
Today it happened after creating some template categories.
I’m not seeing anything that’s working unexpectedly in my testing, so maybe you can clarify where the problem is. From what I’m seeing, it looks like an em dash is a special character so it’s not a valid character to have in a template name. That means that when you put an em dash in your template title like Section – Posts it gets converted into a string of valid characters like section-%e2%80%93-posts. The options I see would be to either:
Work as you normally would and use the auto-generated template name to refer to it, like <Template name="section-%e2%80%93-posts" />
Don’t use em dashes in your template name
Instead of relying on the automatically generated template name that might be a bit ugly because of the em dash you’ve got in the template title, modify the name to something more legible like section-posts and update the template.
Let me know if that makes sense or if I’m missing something about the issue you’re describing.
@benjamin I’ve seen this issue elsewhere with the entire editor content being affected. Definitely worth flagging as a bug. I’ll send you a link to an affected site (up until now it’s only been happening on local installs)
@Rips We looked into the issue Julia was describing it seems that when you check the “Disable the visual editor when writing” checkbox on your user profile, weird things happen when saving in the L&L template editor. But I don’t think that’s related to the issue you’re describing with template names/slugs. Let me know if my answer above makes sense or if there’s some other bug going on.
I am not really sure how these EM dashes find their way into my template names. It could have been a mistake while copying and pasting names or something.
I think what is going wrong here is that EM dashes are not being processed correctly by L&L when saving the template.
When I save a template with title Section – Posts the slug becomes section-%e2%80%93-posts, but the includes Hex UTF-8 code which causes problems.
It would be better if L&L handled an EM dash the same way a WP post does:
Thanks @avanti, I created an issue about that here. I assume this isn’t really a bug and is instead just a limitation of the default URL-safe encoding process L&L uses to auto-generate safe template slugs. We can look into finding an appropriate way to support accents in titles in a more predictable way.
Yeah, that’s what I suggested in the issue on Github. I imagine at the moment, the mechanism for sanitizing/encoding template slugs is to use the same process that Format slug already uses, which keeps the special characters intact (albeit in a URL-friendly format) instead of converting them to their accentless version. You’re totally right though that this probably isn’t the optimal behaviour and that saving template names (as well as formatting things with Format slug) should remove accents altogether since we already have Format url_query designed to keep the special characters intact. I’ve edited my issue to mention that it might be valuable to fix both of these at the same time in case they don’t already rely on the same mechanism.
Limits the output to alphanumeric characters, underscore (_) and dash (-).
…This function does not replace special accented characters.
It actually removes all accented characters.
To convert them to regular characters, there’s a function called remove_accents. In commit a7af4a1, I updated the template save and format slugify functions to apply this.
Hi @benjamin, great, thanks for the update, i can confirm it works, french accented characters in the Template title are now converted to their non-accented version in the template slug.
Thanks for the explanation as well, this is instructive.
Hi @benjamin,
I encounter the same issue with <Format slug />, accented characters are converted instead of simply being unaccented.
Example: é becoming %c3% instead of e
@avanti odd, when this was initially implemented, I’m pretty sure it was addressed for both the template-saving step as well as <Format slug>, but you’re right, I just tested on the latest version and while templates seems to save correctly, the Format tag isn’t properly removing accents. I’ve reported it here.