Class: Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeContext

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_recipientsObject (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


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