Sha256: e51ff3d0e91186848642f4e2d6581f71d22993f4f9b315870f21288352c31b82
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
module Almanack module ServerContext module Environment def basename(file) Pathname(file).split.last.to_s.split(".", 2).first end def locate_asset(name, within: path) name = basename(name) path = settings.root.join(within) available = Pathname.glob(path.join("*")) asset = available.find { |path| basename(path) == name } raise "Could not find stylesheet #{name} inside #{available}" if asset.nil? asset end def auto_render_template(asset) renderer = asset.extname.split(".").last content = asset.read respond_to?(renderer) ? send(renderer, content) : content end def auto_render_asset(*args) auto_render_template locate_asset(*args) end def theme_stylesheet_path settings.root.join('stylesheets') end def register_sass_loadpaths! if !SassC.load_paths.include?(theme_stylesheet_path) SassC.load_paths << theme_stylesheet_path end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems