jorisnoo/statamic-safe-entities
最新稳定版本:0.2.0
Composer 安装命令:
composer require jorisnoo/statamic-safe-entities
包简介
A Statamic addon that provides a Blade directive and Bard buttons for safe HTML entity insertion (soft hyphens, non-breaking spaces, etc.).
README 文档
README
A Statamic addon for safe HTML entity insertion in Bard, text, and textarea fields. Adds a Bard toolbar button for inserting soft hyphens, non-breaking spaces, en dashes, and other typography entities, plus Blade directives to render them safely.
Installation
composer require jorisnoo/statamic-safe-entities
Configuration
Publish the config file to customize which entities are available:
php artisan vendor:publish --tag="safe-entities-config"
Default configuration:
return [ 'entities' => [ '­' => 'Soft Hyphen', ' ' => 'Non-Breaking Space', '–' => 'En Dash', ], ];
Each entry maps an entity code to a label shown in the Bard toolbar dropdown.
Usage
Bard toolbar
The addon adds an "&" button to the Bard toolbar. Clicking it shows a dropdown of configured entities. Selecting one inserts the entity code at the cursor position.
Blade directives
Two Blade directives are available for rendering entities safely:
@entities($text) — for text/textarea fields
Escapes the string for safe HTML output, then restores configured entity codes so they render as actual entities.
<p>@entities($entry->title)</p>
@entitiesHtml($html) — for Bard/rich-text fields
Restores double-encoded entities (&shy; back to ­) in already-rendered HTML.
<div>@entitiesHtml($entry->content)</div>
PHP
You can also call the methods directly:
use Noo\SafeEntities\SafeEntities; $text = SafeEntities::render($value); $html = SafeEntities::renderHtml($value);
Both methods accept an optional second argument to override which entities to restore:
SafeEntities::render($value, ['­', ' ']);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 114
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-18