method

to_trix_html

Importance_1
v7.1.3.2 - Show latest stable - 0 notes - Class: RichText
to_trix_html() public

Returns the body attribute in a format that makes it editable in the Trix editor. Previews of attachments are rendered inline.

content = "<h1>Funny Times!</h1><figure data-trix-attachment='{\"sgid\":\"..."\}'></figure>"
message = Message.create!(content: content)
message.content.to_trix_html # =>
# <div class="trix-content">
#   <h1>Funny times!</h1>
#   <figure data-trix-attachment='{\"sgid\":\"..."\}'>
#      <img src="http://example.org/rails/active_storage/.../funny.jpg">
#   </figure>
# </div>
Show source
Register or log in to add new notes.