Module: Eldr::Rendering

Defined in:
lib/eldr/rendering.rb,
lib/eldr/rendering/version.rb,
lib/eldr/rendering/tag_helpers.rb,
lib/eldr/rendering/output_helpers.rb

Defined Under Namespace

Modules: Output, Tags Classes: NotFound

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



27
28
29
30
# File 'lib/eldr/rendering.rb', line 27

def self.included(klass)
  klass.include Tags
  klass.include Output
end

Instance Method Details

#find_template(path) ⇒ Object

Raises:

  • (StandardError)


18
19
20
21
22
23
24
25
# File 'lib/eldr/rendering.rb', line 18

def find_template(path)
  configuration.engine ||= 'slim'
  raise StandardError, 'Eldr::Rendering requires you to set config.views_dir' unless configuration.views_dir
  template = Pathname.new(File.join(configuration.views_dir, path))
  template = Pathname.new(template.to_s + '.' + configuration.engine) if template.extname.blank?
  raise NotFound, 'Template Not Found' unless File.exist? template
  template.to_s
end

#render(path, resp_code = 200) ⇒ Object



14
15
16
# File 'lib/eldr/rendering.rb', line 14

def render(path, resp_code = 200)
  Rack::Response.new Tilt.new(find_template(path)).render(self), resp_code
end