I'm using Stimulus and ActionText to handle 'mentions', following the tutorial below;
User @mentions with ActionText
When displaying the actiontext content, the partial for each 'mention' is rendered from a json.builder file.
The issue that I'm having is that the actiontext content is within a turbo frame, and the mention partial contains a link. Therefore I need to add the following attribute to escape the turbo frame:
"data-turbo-frame": "_top"
For some reason, this attribute is being stripped from the page when rendering. (Using html.slim).
= link_to character.name, character_path(character), "data-turbo-frame": "_top", class: "font-semibold #{character.color} mention hover-trigger"
Resultant HTML:
<a class="font-semibold text-pink-700 mention hover-trigger" href="/characters/1">Example Character Name</a>
ActionText strips tags and html attributes that aren't whitelisted, including 'style' and the 'data-turbo-frame' attribute. To prevent this for a specific attribute, add the following to an initializer e.g. config/initializers/action_text.rb.
ActionText::Attachment::ATTRIBUTES << 'data-turbo-frame'