From d5623dc634dc6e8ce8294485e1fdb6adb5f16271 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 7 Jun 2018 14:38:41 +0200 Subject: Provide to_html rendering within a layout and use that as the to_s default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I like the idea of thinking about the rendering as happening within a layout. Since that’s basically what this wrapper is. Thoughts @javan? --- lib/action_text/content.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/action_text') 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 - "
#{to_html}
".html_safe + to_html_with_layout end def as_json(*) -- cgit v1.2.3