Class: Context
- Inherits:
-
Object
- Object
- Context
- Includes:
- Rack::Utils
- Defined in:
- lib/html2email/context.rb
Overview
Templates are evaluated in the scope of Context.new
Defined Under Namespace
Classes: Attr, PrebindingException
Instance Attribute Summary collapse
-
#test_recipients ⇒ Object
readonly
Returns the value of attribute test_recipients.
Instance Method Summary collapse
- #add_test_recipients(*list) ⇒ Object
- #image_tag(src, opts = {}) ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #link_to(text, url, opts = {}) ⇒ Object
- #prebinding(&block) ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
20 21 22 |
# File 'lib/html2email/context.rb', line 20 def initialize @binding, @test_recipients = nil, [] end |
Instance Attribute Details
#test_recipients ⇒ Object (readonly)
Returns the value of attribute test_recipients.
30 31 32 |
# File 'lib/html2email/context.rb', line 30 def test_recipients @test_recipients end |
Instance Method Details
#add_test_recipients(*list) ⇒ Object
31 32 33 |
# File 'lib/html2email/context.rb', line 31 def add_test_recipients(*list) @test_recipients += list.flatten end |
#image_tag(src, opts = {}) ⇒ Object
39 40 41 |
# File 'lib/html2email/context.rb', line 39 def image_tag(src, opts = {}) %Q(<img src='#{h src}' #{Attr[opts]} />) end |
#link_to(text, url, opts = {}) ⇒ Object
35 36 37 |
# File 'lib/html2email/context.rb', line 35 def link_to(text, url, opts = {}) %Q(<a href='#{h url}' target='_blank' #{Attr[opts]}>#{text}</a>) end |
#prebinding(&block) ⇒ Object
24 25 26 27 28 |
# File 'lib/html2email/context.rb', line 24 def prebinding(&block) return if @binding @binding = (block.call; binding) raise PrebindingException end |