Skip to content

Trek::Contentable ​

Utilities for rich text stored as ProseMirror JSON in a content column — the format produced by Trek's content editor.

Methods ​

MethodReturns
parsed_contentthe content as a hash (parsing JSON strings if needed)
formatted_contentsafe HTML, rendered through the ProseMirror pipeline
content_textplain text extracted from all text nodes
prosemirror_content?whether content is a valid ProseMirror document

Usage ​

ruby
class Page < ApplicationRecord
  include Trek::Contentable
end

page.formatted_content # => "<p>Hello <strong>world</strong></p>"
page.content_text      # => "Hello world"

Requirements ​

Released under the MIT License.