Sha256: 26d6d88ca4314504acb229f36dc4c509dd37cc291a3d0f3c66725a44fb4c6f2e
Contents?: true
Size: 1.26 KB
Versions: 6
Compression:
Stored size: 1.26 KB
Contents
module Less module Rails class LessTemplate < Tilt::LessTemplate self.default_mime_type = 'text/css' include Helpers TO_CSS_KEYS = [:compress, :optimization, :silent, :color] def prepare end def evaluate(scope, locals, &block) @output ||= begin Less.Parser['scope'] = scope parser = ::Less::Parser.new config_to_less_parser_options(scope) engine = parser.parse(data) engine.to_css config_to_css_options(scope) end end protected def config_to_less_parser_options(scope) paths = config_paths(scope) + scope.environment.paths local_path = scope.pathname.dirname paths += [local_path] unless paths.include? local_path {:filename => eval_file, :line => line, :paths => paths, :dumpLineNumbers => config_from_rails(scope).line_numbers} end def config_to_css_options(scope) Hash[config_from_rails(scope).each.to_a].slice *TO_CSS_KEYS end def config_paths(scope) config_from_rails(scope)[:paths] end def config_from_rails(scope) scope.environment.context_class.less_config end end end end
Version data entries
6 entries across 6 versions & 1 rubygems