Class: EasyForm::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_form/template.rb

Class Method Summary collapse

Class Method Details

.cache(name) ⇒ Object



9
10
11
# File 'lib/easy_form/template.rb', line 9

def cache(name)
  store[name] ||= yield
end

.render(template_name, binding) ⇒ Object



13
14
15
16
17
18
# File 'lib/easy_form/template.rb', line 13

def render(template_name, binding)
  template = cache template_name do
    File.read [Rails.root, '/app/views/easy_form/_', template_name, '.html.erb'].join
  end
  ERB.new(template).result(binding).html_safe
end

.storeObject



4
5
6
7
# File 'lib/easy_form/template.rb', line 4

def store
  return {} if Rails.env.development?
  @store ||= {}
end