Kirby Tag without arguments

I’ve create a new Kirbytag without arguments with the following code:

[...]
'tags' => [
  'br' => [
    'html' => function($tag) {
      return '<br>';
    }
  ]
]
[...]

Unfortunately the tag only works if I use (br:) and not (br). Are arguments always required despite being empty?

Why do you need a tag at all?

Kirbytags always need the colons to separate the type and the values,

$tag  = trim(rtrim(ltrim($string, '('), ')'));
$type = trim(substr($tag, 0, strpos($tag, ':')));

To insert a <br> tag using markdown, you can use 4 spaces at the end of a line.

The reason why I need an additional br tag is because I need to add <br> tags into h1 and h2 titles, but I am escaping the whole content which removes those tags.

In any case, you have to use the colon, without the colon, Kirby couldn’t separate a Kirbytag from normal text in parentheses.

If you absolutely don’t want to use the colon, you could use regex and a kirbytags:after hook to replace your (br) strings.

1 Like