KirbyTags
Default KirbyTags
Kirby comes with a set of default KirbyTags for things like including images, links, dates or videos into text fields. See the full list of included KirbyTags.
How to use your own KirbyTag
You can create and use a tag like (wikipedia:)
in text fields. For this to work, you have to include a function ->kirbytext()
for every field in the template that you wish should support this tag. You can also use KirbyTags directly in your templates. See parsing KirbyTags in your text.
How to create your own KirbyTag
Because of a limitation in Parsedown, the Markdown parser currently used by Kirby, the HTML code you return from your tag should not contain extraneous whitespace, e.g. a line break directly after the tag name of an HTML tag. Otherwise your tag output may be escaped by Parsedown.
If your tag output is messed up, please check if your returned HTML code contains code like this:
Outsourcing code to separate file
And then in /tags/wikipedia.php
Overriding default KirbyTags
You can override Kirby's default KirbyTags by creating a plugin with the same KirbyTag name as the original.
Adding attributes
If you want to add attributes (e.g. (wikipedia: class: my-class)
), you can add them as an attr
array like this:
Accessing attributes and Kirby objects
The properties of the $tag
object can be accessed like this:
The tag's value
Attributes
Array of all used attributes
The parent page object
Files
Options
The KirbyTag type
KirbyTag hooks
In addition to your own KirbyTag plugins, you can also hook into the KirbyTags parser. This is very useful if you want to parse the text before or after the KirbyTags parser kicks in with additional regular expressions for example.
kirbytags:before
kirbytags:after
Reusing parts of existing KirbyTags
You can also reuse parts of the original KirbyTag in your custom tags.