Class: Markaby::Rails::TemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/markaby/rails.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.optionsObject

TODO: Do we need this? Default format used by Markaby class_attribute :default_format self.default_format = :html



17
18
19
# File 'lib/markaby/rails.rb', line 17

def options
  @options ||= {}
end

.options=(val) ⇒ Object



21
22
23
24
# File 'lib/markaby/rails.rb', line 21

def options=(val)
  options.merge!(val)
  options
end

.register!(options = {}) ⇒ Object



7
8
9
10
# File 'lib/markaby/rails.rb', line 7

def register!(options = {})
  self.options = options
  ActionView::Template.register_template_handler(:mab, new)
end

Instance Method Details

#call(template, source = template.source) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/markaby/rails.rb', line 27

def call(template, source = template.source)
  <<-CODE
    Markaby::Builder.new(Markaby::Rails::TemplateHandler.options, self) do
      #{source}
    end.to_s
  CODE
end