diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-04-02 17:15:41 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-04-07 17:14:07 +0100 |
commit | 3954e78a4d330e3e9d82be0d239d5bf25d2f6a04 (patch) | |
tree | 2f2a031b3705396497862b7d29d1967481b55182 /lib/attachment_to_html/view.rb | |
parent | cb06289e9fc04bf2ea9430828358a7cf304eae8f (diff) |
Dynamically inject AttachmentToHTML::View content
Diffstat (limited to 'lib/attachment_to_html/view.rb')
-rw-r--r-- | lib/attachment_to_html/view.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/attachment_to_html/view.rb b/lib/attachment_to_html/view.rb index 5cdd3823b..e6991d44e 100644 --- a/lib/attachment_to_html/view.rb +++ b/lib/attachment_to_html/view.rb @@ -19,9 +19,21 @@ module AttachmentToHTML super(File.read(template)) end - def render + def render(&block) + instance_eval(&block) if block_given? result(binding) end + def content_for(area) + send(area) if respond_to?(area) + end + + private + + def inject_content(area, &block) + instance_variable_set("@#{ area }".to_sym, block.call) + self.class.send(:attr_accessor, area) + end + end end |