kirbytextWrap - Remove or replace enclosing p tag and more

plugin
field
#1

Hello,
I made my first Kirby Plugin! Let me introduce you KirbytextWrap().

Remove OR replace the <p> </p> enclosing tag on kirbytext() and add somes HTML attributes.

  • Work for both K2 and K3 version.
  • CLI and Composer support.
  • Keep yours kirbytag working.

Usage:
$page->title()->kirbytextWrap('h1') Will replace the <p> enclosing tag by <h1>.
$page->title()->kirbytextWrap('h1', ['class' => 'title']) Will replace the <p> enclosing tag by <h1> and add a class attribute with its value.

Another example with more attributes:

<?php
$attr = [
    'class' => 'dallas',
    'id' => 'larry',
    'aria-hidden' => 'true',
    'data-animation' => true,
];

echo $page->title()->kirbytextWrap('p', $attr);

Feel free to report bug or suggestion.
Download and docs: https://github.com/yoanmalie/kirbytextWrap

1 Like

#2

Update v1.1.0!
It uses the new kirbytextinline() method available since Kirby 3.1.0 and still support the Kirby 2 and Kirby 3.0 versions :slight_smile: .

0 Likes