jorisnoo/statamic-safe-entities
A Statamic addon for safely handling HTML entities in Antlers templates, helping prevent double-escaping and ensuring entities render correctly when outputting content.
composer require jorisnoo/statamic-safe-entities. The addon is auto-discovered by Statamic; there is typically no service provider to register by hand. Check whether a config file is shipped — if so, publish it and commit it so entity/typographic behaviour is consistent across environments.src/Modifiers/ to confirm the exact modifier handle (this is a Statamic modifier addon, so the public API is the modifier name, not a facade), then the README for the documented signature and any config keys. Skim CHANGELOG.md before installing: 0.2.2 removed the auto-hyphenation feature and its dependencies, so any snippet you copy from an older blog post that mentions soft hyphens no longer applies.&, <, curly quotes, em dashes) is output as entities without corrupting already-encoded content.
<h2>{{ headline | safe_entities }}</h2>
& and confirm whether you need | raw downstream or whether the modifier is designed to be used inside an escaped context. This is the single decision that determines how you wire it everywhere else.0.2.2 is a breaking change in a 0.x line — use "jorisnoo/statamic-safe-entities": "0.2.2" (or ^0.2.2) rather than * so a future 0.x removal doesn't surprise a deploy.partials/text) that owns escaping/entity handling and takes a text parameter. Every heading, caption, and rich-text excerpt renders through it. When the addon's behaviour changes again, you edit one file.safe_entities after transformations that introduce characters and before anything that re-parses HTML.
{{ content | markdown | safe_entities }}
If you need widont/smartypants-style typographic passes, run them before safe_entities so the entities it produces are the final form. Do not run it after a modifier that expects raw &/<.Statamic::modify($text)->safeEntities(), which keeps behaviour identical between Antlers and Blade views — useful when a Livewire component renders the same field as an Antlers template.safe_entities only at output. This keeps the Statamic search index, the CP preview, and any API/JSON consumers clean.{{ cache }} tag so the entity pass and surrounding markup are computed once.­:
$this->get('/')->assertDontSee('­', false);
and a snapshot/assertSee test for a known string with curly quotes and an ampersand. This is the fastest way to catch both the hyphenation removal and any accidental double-encoding.{{ }} output by default; if the modifier already returns &, you can end up with &amp; on screen. Establish early whether the modifier returns a "safe" string (so no | raw is needed) or expects | raw. Test with a value containing &, <, and an existing &.lang on <html>, then hyphens: auto; overflow-wrap: break-word; on the affected selectors. Budget design QA time for headline/card layouts after upgrading.json_encode-style escaping, not HTML entities; run the modifier only on the HTML rendering path. Same for alt attributes and title attributes where & will be re-decoded inconsistently by different crawlers.php artisan config:clear && php artisan view:clear (and php please stache:clear if you changed field-level rendering). Leftover config keys after a removal are silent no-ops that make debugging confusing.mb_* vs byte functions diverge; a passing ASCII test proves nothing.™, ®) it is often cleaner to copy the modifier into app/Modifiers/ and register your own handle than to patch vendor code. If the addon allows config-driven replacement maps, prefer that and keep the override in config/statamic/safe-entities.php.{{ dump }} or php please tinker to compare raw field value vs. modifier output when something renders literally as &. If output looks stale, Statamic's view/stache caches are the usual culprits, not the modifier.composer update to be safe.How can I help you explore Laravel packages today?