Module: Tight::Engine::Template

Defined in:
lib/tight-engine/template.rb

Instance Method Summary collapse

Instance Method Details

#element(name, *args) ⇒ Object



8
9
10
11
# File 'lib/tight-engine/template.rb', line 8

def element( name, *args )
  opts = Hash === args.last ? args.pop : {}
  defer_element( name, args, opts ) || process_element( name, args, opts )
end

#element_view(name, opts = {}) ⇒ Object



13
14
15
# File 'lib/tight-engine/template.rb', line 13

def element_view( name, opts = {} )
  fragment name, :elements, opts
end

#fragment(template, type = nil, opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/tight-engine/template.rb', line 17

def fragment( template, type = nil, opts = {} )
  opts, type = type, nil  if type.kind_of? Hash
  opts[:layout] ||= false
  type ||= :fragments
  render :slim, :"#{type}/#{template}", opts
rescue Padrino::Rendering::TemplateNotFound, Errno::ENOENT => e
  name = template.partition('/').first
  report_error e, "EngineHelpers##{__method__}@#{__LINE__}", "[#{type.to_s.singularize.camelize} '#{name}' error: #{e.to_s.strip}]"
end

#process_pageObject



4
5
6
# File 'lib/tight-engine/template.rb', line 4

def process_page
  process_deferred_elements fragment( @page.fragment_id, :layout => :"layouts/#{@page.layout_id}" )
end