aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_text/content.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-06-07 14:38:41 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-06-07 14:38:41 +0200
commitd5623dc634dc6e8ce8294485e1fdb6adb5f16271 (patch)
tree0f94b7dc2ed41baa9d007601862ac2c9451a735b /lib/action_text/content.rb
parent9e5ab1ebd9a80a78f9daaf38a9ee244e60b8af1c (diff)
downloadrails-d5623dc634dc6e8ce8294485e1fdb6adb5f16271.tar.gz
rails-d5623dc634dc6e8ce8294485e1fdb6adb5f16271.tar.bz2
rails-d5623dc634dc6e8ce8294485e1fdb6adb5f16271.zip
Provide to_html rendering within a layout and use that as the to_s default
I like the idea of thinking about the rendering as happening within a layout. Since that’s basically what this wrapper is. Thoughts @javan?
Diffstat (limited to 'lib/action_text/content.rb')
-rw-r--r--lib/action_text/content.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/action_text/content.rb b/lib/action_text/content.rb
index ce40505329..2eff8bb361 100644
--- a/lib/action_text/content.rb
+++ b/lib/action_text/content.rb
@@ -53,8 +53,12 @@ module ActionText
end.to_html
end
+ def to_html_with_layout
+ ActionText.renderer.render(partial: "action_text/content/layout", locals: { document: to_html.html_safe }).html_safe
+ end
+
def to_s
- "<div class='trix-content'>#{to_html}</div>".html_safe
+ to_html_with_layout
end
def as_json(*)