Sha256: fc05a36740ab95286656e767d138cb13c3b2e5518c0cf3fda9a9c98692caa6ae

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module Plate
  # Slightly modified from the Tilt default to just use the Less::Parse instead of Engine.
  #
  # Also adds support for paths
  #
  # Original source: https://github.com/rtomayko/tilt/blob/master/lib/tilt/css.rb
  class LessTemplate < Tilt::Template
    self.default_mime_type = 'text/css'

    def self.engine_initialized?
      defined? ::Less
    end

    def initialize_engine
      require_template_library 'less'
    end

    def prepare
    end

    def evaluate(scope, locals, &block)
      paths = [ scope.pathname, File.join(scope.site.source, 'content') ]

      less_options = options.merge({
        :filename => eval_file,
        :line => line,
        :paths => paths
      })

      parser  = ::Less::Parser.new(less_options)
      parser.parse(data).to_css
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plate-0.6.0 lib/plate/less_template.rb