Quicktip: Reusing KirbyTags in custom tags
Sometimes, you may want to extend an existing KirbyTag in a custom KirbyTag, for example, to add attributes or to modify the HTML output.
To prevent having to copy the complete code, you can reuse parts of the original tag. With…
…you get access to the original
…you have access to the original attributes.
…to the original HTML.
Using the following code we can thus reuse the attributes array and put a wrapper around the original HTML.
We can also extend the attributes array by merging it with new attributes, and replace parts of the original HTML using string replacement:
If you store the original tag in a variable outside the plugin wrapper like in the examples, you can override the original tag by using the same tag name instead of the custom names.