Method: Post#content

Defined in:
lib/ecrire/app/models/post.rb

#contentObject

Returns the content of this post. Depending on the current status of this post, it can be one of three things:

  • Compiled content;

  • Markdown content;

  • Empty string.

This method should be used when trying to render the body of a post to a page in HTML.



131
132
133
134
135
136
# File 'lib/ecrire/app/models/post.rb', line 131

def content
  @content ||= begin
    content = read_attribute('content')
    Content.new(content.fetch('raw', ''), content.fetch('html', '').html_safe)
  end
end