class Stylio::App

Public Instance Methods

choose_fixture(path, name) click to toggle source
# File lib/stylio/app.rb, line 104
def choose_fixture(path, name)
  if File.exists?(File.join("#{path}/#{ name }.yml.erb"))
    YAML.load(erb(:"#{path}/#{ name }.yml"))
  else
    YAML.load_file(File.join(path, "#{name}.yml"))
  end
end
find_files(type) click to toggle source
# File lib/stylio/app.rb, line 98
def find_files(type)
  root_folder = File.join(settings.app_path, type)
  directories = Dir.entries(root_folder).select {|f| !File.directory? f}
  directories.sort
end
render_application_partial(key, opts = {}) click to toggle source
# File lib/stylio/app.rb, line 130
def render_application_partial(key, opts = {})
  file = File.join(settings.app_path, 'stylio', key.to_s)
  if File.exist?("#{file}.erb")
    erb :"#{file}", opts
  else
    erb key, opts
  end
end
render_component(name, key) click to toggle source
# File lib/stylio/app.rb, line 113
def render_component(name, key)
  path = File.join(settings.app_path, 'components', name)
  yaml = YAML.load_file(File.join(path, "#{ name }.yml"))
  erb(:"#{path}/_#{name}.html", locals: { params: yaml[key.to_s] })
end
render_yield(key) click to toggle source
# File lib/stylio/app.rb, line 125
def render_yield(key)
  path = File.join(settings.app_path, request.path_info)
  erb :"#{path}/_#{key}.html"
end
sub_component(name, key) click to toggle source
# File lib/stylio/app.rb, line 119
def sub_component(name, key)
  path = File.join(settings.app_path, 'components', name)
  yaml = YAML.load_file(File.join(path, "#{ name }.yml"))
  erb(:"#{path}/_#{name}.html", locals: { params: yaml[key.to_s] }).dump[1...-1].gsub('\n', '')
end