class Simplerb::Base

Constants

HTTP_VERBS

Public Instance Methods

partial(partial) click to toggle source
# File lib/simplerb.rb, line 26
def partial(partial)
  # Put underscore in last path component
  file_path = partial.gsub(/(.*)\//, '\1/_')
  full_path = File.join(settings.views, "#{file_path}.erb")

  if view_files('_*.erb').include? full_path
    erb file_path.to_sym, layout: false
  else
    raise "Couldn't find partial '#{partial}' at path '#{full_path}'"
  end
end
view_files(pattern = '*') click to toggle source
# File lib/simplerb.rb, line 22
def view_files(pattern = '*')
  Dir.glob(File.join(settings.views, '**', pattern))
end