Module: Nesta::Overrides::Renderers

Defined in:
lib/nesta/overrides.rb

Instance Method Summary collapse

Instance Method Details

#find_template(views, name, engine, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/nesta/overrides.rb', line 4

def find_template(views, name, engine, &block)
  user_paths = [
    Nesta::Overrides.local_view_path,
    Nesta::Overrides.theme_view_path,
    views
  ].flatten.compact
  user_paths.each do |path|
    super(path, name, engine, &block)
  end
end

#sass(template, options = {}, locals = {}) ⇒ Object

Raises:

  • (IOError)


22
23
24
25
26
27
# File 'lib/nesta/overrides.rb', line 22

def sass(template, options = {}, locals = {})
  find_template(Nesta::App.settings.views, template, Tilt::SassTemplate) do |file|
    return Tilt.new(file).render if File.exist?(file)
  end
  raise IOError, "Sass template not found: #{template}"
end

#scss(template, options = {}, locals = {}) ⇒ Object

Raises:

  • (IOError)


15
16
17
18
19
20
# File 'lib/nesta/overrides.rb', line 15

def scss(template, options = {}, locals = {})
  find_template(Nesta::App.settings.views, template, Tilt::ScssTemplate) do |file|
    return Tilt.new(file).render if File.exist?(file)
  end
  raise IOError, "SCSS template not found: #{template}"
end

#stylesheet(template, options = {}, locals = {}) ⇒ Object



29
30
31
32
33
# File 'lib/nesta/overrides.rb', line 29

def stylesheet(template, options = {}, locals = {})
  scss(template, options, locals)
rescue IOError
  sass(template, options, locals)
end