Module: WithTemplate::ViewAdditions

Defined in:
lib/with_template/view_additions.rb

Instance Method Summary collapse

Instance Method Details

#global_templateObject



21
22
23
24
25
26
27
28
29
# File 'lib/with_template/view_additions.rb', line 21

def global_template
  if @global_template.blank?
    @global_template = WithTemplate::Base.new(self)
    @global_template.blocks = blocks.blocks
    @global_template.skipped_blocks = blocks.skipped_blocks
    @global_template.anonymous_block_number = blocks.anonymous_block_number
  end
  @global_template
end

#with_global_template(template, options = {}, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/with_template/view_additions.rb', line 9

def with_global_template(template, options={}, &block)
  options = options.with_indifferent_access
  variable = options.delete(:variable) || :global_template
  if @global_template.present?
    @global_template.init_options.reverse_merge!(options)
    @global_template.global_options.merge!(@global_template.init_options)
  else
    @global_template = WithTemplate::Base.new(self, options)
  end
  @global_template.render_template(template, variable, &block)
end

#with_template(template, options = {}, &block) ⇒ Object



3
4
5
6
7
# File 'lib/with_template/view_additions.rb', line 3

def with_template(template, options={}, &block)
  options = options.with_indifferent_access
  template_variable = options.delete(:variable) || :template
  WithTemplate::Base.new(self, options).render_template(template, template_variable, &block)
end