lib/ahc.rb in ahc-0.2.1 vs lib/ahc.rb in ahc-0.2.2

- old
+ new

@@ -1,19 +1,23 @@ require 'erubis' require 'ahcx_template_handler' class Ahc - def self.render(template_name, params) + def self.render(template_name, params, css_map = {}) if @@templates[template_name] - return @@templates[template_name].result({:params => params}).strip + css = lambda {|css_class| + @@css_map[css_class] || css_class + } + return @@templates[template_name].result({:params => params, :css => css}).strip end return '' end def self.read_templates(paths) @@templates = {} + @@css_map ||= {} paths.each do |path| if File.directory?(path) Dir.glob(path+"/**/*.css") do |item| next if File.directory?(item) provides = css_provides(item) @@ -22,9 +26,13 @@ @@templates[provide] = template if template end end end end + end + + def self.set_css_map(css_map) + @@css_map = css_map end def self.css_provides(stylesheet_path) provides = [] File.readlines(stylesheet_path).each do |line|