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

Smartypants is applied before Antlers #11302

Open
efc opened this issue Dec 23, 2024 · 3 comments
Open

Smartypants is applied before Antlers #11302

efc opened this issue Dec 23, 2024 · 3 comments

Comments

@efc
Copy link

efc commented Dec 23, 2024

Bug description

When I check both Smartypants and Antlers on a field, Smartypants is applied before Antlers. This can cause Antlers to fail since it does not know how to deal with the curly quotes.

How to reproduce

  1. Make sure that content on your pages has both Smartypants and Antlers checked.
  2. Create a page that includes the following.
---
[other YAML omitted]
description: This cat video is the okayest thing ever.
---
Trying to replace...

{{ description | replace("cat", "dog") }}

With quotes...

{{ collection:pages as="pages" }}
    {{ pages }}
        {{ title }}
    {{ /pages }}
{{ /collection:pages }}

Without quotes...

{{ collection:pages }}
    {{ title }}
{{ /collection:pages }}

When rendering the page notice that the replacement does not happy, the first collection with an alias does not work. But the last collection does work.

Logs

No response

Environment

Environment
Application Name: Tensegrities
Laravel Version: 11.36.1
PHP Version: 8.3.14
Composer Version: 2.8.3
Environment: local
Debug Mode: ENABLED
URL: mary.test/web
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 7
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.45.0 Solo

Statamic Addons
alt-design/alt-redirect: 1.3.3
heidkaemper/statamic-toolbar: 1.3.0
jacksleight/statamic-bonus-routes: 0.3.2
mitydigital/feedamic: 2.5.0
statamic/importer: 1.6.0
statamic/ssg: 3.1.0
trendyminds/statamic-palette: 1.2.1

Installation

Fresh statamic/statamic site via CLI

Additional details

Also related, when Antlers is checked on a field, many other modifiers stop working altogether. It is as though a field with Antlers processing does not pass along a value at all.

@duncanmcclean
Copy link
Member

duncanmcclean commented Jan 2, 2025

This isn't valid Antlers:

{{ collection:pages as "pages" }}

It should be:

{{ collection:pages as="pages" }}

@efc
Copy link
Author

efc commented Jan 3, 2025

True, but not relevant to this point, it does not work even when corrected.

@efc
Copy link
Author

efc commented Jan 3, 2025

I have discovered that when antlers is turned on for a field, then the field returns an AntlersString instead of a regular PHP string, which causes some modifiers to fail. In my own modifiers I now use a $value="$value"; at the start of the method to make sure I am dealing with a plain string.

I have also learned that if I turn smartypants off in the field definition, but then use the smartypants modifier on the filed, I can both allow Antlers to process the content and smartypants to clean it up.

A good, simple Antlers test case is {{ now | iso_format("YYYY") }} which will fail if the quotes are curled but work fine if they are not.

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

No branches or pull requests

2 participants