Module: Panda::CMS::Admin::PostsHelper
- Defined in:
- app/helpers/panda/cms/admin/posts_helper.rb
Instance Method Summary collapse
Instance Method Details
#editor_content_for(post, preserved_content = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/panda/cms/admin/posts_helper.rb', line 7 def editor_content_for(post, preserved_content = nil) content = preserved_content || post.content # Return empty structure if no content json_content = if content.blank? {blocks: []}.to_json # If content is already JSON string, use it elsif content.is_a?(String) && valid_json?(content) content # If it's a hash, convert to JSON elsif content.is_a?(Hash) content.to_json # Default to empty structure else {blocks: []}.to_json end # Base64 encode the JSON content Base64.strict_encode64(json_content) end |