Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure_right doesn't work with | #4249

Closed
tao opened this issue Sep 11, 2021 · 3 comments · Fixed by #4257
Closed

ensure_right doesn't work with | #4249

tao opened this issue Sep 11, 2021 · 3 comments · Fixed by #4257

Comments

@tao
Copy link
Contributor

tao commented Sep 11, 2021

Bug Description

I'm working on SEO titles for my website, the common convention is to use title | site name. I'm overriding some of my pages and want to fall back to site name when I break something... I want to avoid | site name in the title.

I thought I'd use ensure_right to get around this:

<title>{{ title ensure_right=" |" }} {{ config:app:name }}</title>

However, I found this doesn't work. I assume | is reserved for use in conditional statements or the parser is getting confused about it. Although I found that & works fine.

With different characters it works as expected:

<title>{{ title ensure_right=" @" }} {{ config:app:name }}</title>
<title>{{ title ensure_right=" ," }} {{ config:app:name }}</title>
<title>{{ title ensure_right=" ," }} {{ config:app:name }}</title>
<title>{{ title ensure_right=" &" }} {{ config:app:name }}</title>
<title>{{ title ensure_right=" !" }} {{ config:app:name }}</title>

It seems like most other options work fine except |.

Environment

Statamic 3.2.1 Pro
Laravel 8.56.0
PHP 8.0.6
statamic/ssg 0.8.0

@tao
Copy link
Contributor Author

tao commented Sep 11, 2021

If it's a reserved word because we use | for modifiers then the docs just need to be updated.

@JohnathonKoster
Copy link
Contributor

Pretty sure it's getting confused there since | in parameter-style modifiers is used to separate lists.

Would using the HTML entity version work for your use case?

<title>{{ title ensure_right=" &vert;" }}</title>

@tao
Copy link
Contributor Author

tao commented Sep 13, 2021

Using &vert; works, thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants