I’m trying to use the Str::template
method to inject a couple of divs in order to facilitate the styling of an interview.
The setup is pretty simple, I’m using {{ q }}
and {{ /q }}
to mark the beginning and the end of the question and i’m doing the same for the answer.
Then, using the kirbytext:after
hook i’m replacing the placeholders with html tags.
return Str::template($text , [
'q' => '<div class="q">',
'a' => '<div class="a">',
'/q' => '</div>',
'/a' => '</div>',
]);
The problem I’m facing is that there seems to be no way to get the proper markup. if I use the :before hook I get the divs but the text inside it it’s plain text, no <p>
, <a>
etc.
If I use the :after hook then I get A markup that looks like this <p><div class="p>">TEXT</div></p>
Is there a clean way to solve this?