Kirbytext breaking if link

Hello,
I’m using ‘kirbytext’ inside a data attribute in HTML.
Something like:

<a href="#" data-text:"<?php $note->info()->kt() ?>">Link</a>

The output works good except if the markdown includes a link; which makes the link to break.
Is this something that might be related with Kirby or my code?

Thanks,

Hey,

your code should lool like this

<a href="#" data-text="<?= $note->info()->kt()?>">Link</a>

Sorry I missed that! Thanks for pointing out.
The problem persists as I just missed this when copying/paste

I think the problem is caused by closing quotes in the generated HTML which break the tag. Probably not limited to links but anything that has quotes, even it is just some text that contains quotes.

What is your use case for putting HTML in a data attribute? Wouldn’t it make more sense to grab the result via AJAX?

1 Like

That was the problem! Thanks a lot for the answer