Module: Silverdot::ActionViewExtension

Defined in:
lib/silverdot/helpers/action_view_extension.rb

Instance Method Summary collapse

Instance Method Details

#emboss(template, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/silverdot/helpers/action_view_extension.rb', line 3

def emboss(template, options = {})
  with = options[:with]
  with = [with] unless with.is_a?(Enumerable)
  locals = Hash[with.inject([]) do |list, name|
    list << [name.to_sym, Alternative.new(name)]
  end ]
  view = view_renderer.render(self, partial: template, locals: locals)
  if options[:jst]
    to_jst template, raw(::EJS.compile(view.to_str, Silverdot.ejs_options))
  else
    view
  end
end