estd/kirby-modify-text
最新稳定版本:1.0.0
Composer 安装命令:
composer require estd/kirby-modify-text
包简介
A plugin to add custom attributes (e.g., styles, classes) to Kirby CMS writer blocks.
README 文档
README
A Kirby CMS plugin to modify text blocks with custom attributes, classes, inline styles, or HTML tags, offering more control over text styling.
Installation
Composer
Install the plugin via Composer:
composer require estd/kirby-modify-text
Manual Installation
Download this repository and place it in your site/plugins directory. Make sure the folder is named kirby-modify-text.
Usage
Use kirby-modify-text to modify text block HTML with dynamic attributes, styles, classes, or tag changes. Here’s an example of how to use it:
<?php // Define custom styles $styles = [ 'color: red', 'font-weight: bold' ]; // Apply modifications to the text block echo $block->text()->modifyTag([ 'styles' => $styles, // Inline styles as an array 'class' => 'custom-class', // Add one or more CSS classes 'tag' => 'span', // Change the HTML tag (optional) 'attributes' => [ 'data-custom' => 'example' // Add any custom attributes ] ])->kt(); ?>
Or modify the text block as you need
// Change tag <?= $block->text()->modifyTag(['tag' => 'h2'])->kt() ?> // Add styles <?= $block->text()->modifyTag(['styles' => ['color: blue', 'font-weight: bold']])->kt() ?> // Add a attribute <?= $block->text()->modifyTag(['attributes' => ['data-info' => 'example']])->kt() ?>
Options
styles: An array of inline CSS styles to add to the tag.class: A string with CSS classes to add. If the tag already has classes, the new ones will be appended.tag: Specify an HTML tag (e.g.,h2,span). If omitted, the original tag remains unchanged.attributes: An associative array of additional attributes, such asdata-*attributes, that will be added to the tag.
License
MIT License. See the LICENSE file for details.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-03