Coder Social home page Coder Social logo

yoanmalie / kirbytextwrap Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 164 KB

Kirby plugin to get rid of the kirbytext() <p> enclosing tag, or replace them and add HTML attributes. It Keep the kirbytag working.

License: MIT License

PHP 100.00%
kirby kirby-plugin kirby-cms kirby3-plugin kirby-field kirbytext

kirbytextwrap's Introduction

KirbytextWrap plugin for Kirby

GitHub release License Kirby Version_2 Kirby Version_3

Kirby Plugin to remove or replace the <p> </p> enclosing tag and set HTML attributes. This will keep your kirbytag working.
Support both Kirby 2 and Kirby 3 version!


banner

How it works?

In your template, $page->title()->kirbytextWrap() will give you the same as kirbytext() without the <p> enclosing tag. This work also with the short ktw() alias.

Do much more

$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.

Put as many attributes as you want, you better create a variable for your array of attributes.

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

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

Yeah cool but how to install?

You can install the kirbytextWrap plugin manually, with CLI, through Git submodule or with Composer.

  • Manually:
    Just download your desired version through the releases page, unzip and place the given folder into the site/plugin directory and rename it to kirbytextWrap.

  • Kirby CLI:

    kirby plugin:install yoanmalie/kirbytextwrap

    โš ๏ธ This will just work for Kirby 2 has CLI was removed on Kirby 3.

  • Git submodule:

    git submodule add https://github.com/yoanmalie/kirbytextwrap site/plugins/kirbytextWrap
    git submodule update --init --recursive
  • Composer:

    composer require yoanmalie/kirbytextwrap

Contributing

If you see a typo, or found a bug, please let me know! Share also your ideas through the issues tab.
Thanks for your help.

Clone this repo and run npm install.

git clone [email protected]:yoanmalie/kirbytextWrap.git
npm install

On each commit, Prettier will be run.

Credits

๐Ÿคš High five to @judbd who give me this plugin idea.
๐ŸŽฉ Hat tip to Jannik with his kirbytextRaw plugin who helped me when started to develop this plugin!

kirbytextwrap's People

Contributors

yoanmalie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kirbytextwrap's Issues

[K4] 4.0 Compatibility

The plugin doesn't work correctly in K4

echo $page->title()->kirbytextWrap('h1', ['class' => 'title']); // returns just "Home" without tags

Kirby 4.0.0
PHP 8.1.23

multiple paragraphs

The plugin looks really useful, espacially for utility and component classes. I'm wondering if there is a way to add support for mulitple paragraphs styling? So far, it only returns the first paragraph.

Ideally something like this $page->title()->ktw('p', ['class' => 'custom']) would returns:

<p class="custom">...</p>
<p class="custom">...</p>
<p class="custom">...</p>
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.