Sha256: 0a12ee9e7b977e4adc7e1e432af1df4afd8f391270871b6a6dda3525fc8d964d

Contents?: true

Size: 1.58 KB

Versions: 129

Compression:

Stored size: 1.58 KB

Contents

require 'tilt/template'

module Tilt
  # Sass template implementation. See:
  # http://haml.hamptoncatlin.com/
  #
  # Sass templates do not support object scopes, locals, or yield.
  class SassTemplate < Template
    self.default_mime_type = 'text/css'

    def self.engine_initialized?
      defined? ::Sass::Engine
    end

    def initialize_engine
      require_template_library 'sass'
    end

    def prepare
      @engine = ::Sass::Engine.new(data, sass_options)
    end

    def evaluate(scope, locals, &block)
      @output ||= @engine.render
    end

  private
    def sass_options
      options.merge(:filename => eval_file, :line => line, :syntax => :sass)
    end
  end

  # Sass's new .scss type template implementation.
  class ScssTemplate < SassTemplate
    self.default_mime_type = 'text/css'

  private
    def sass_options
      options.merge(:filename => eval_file, :line => line, :syntax => :scss)
    end
  end

   # Lessscss template implementation. See:
  # http://lesscss.org/
  #
  # Less templates do not support object scopes, locals, or yield.
  class LessTemplate < Template
    self.default_mime_type = 'text/css'

    def self.engine_initialized?
      defined? ::Less
    end

    def initialize_engine
      require_template_library 'less'
    end

    def prepare
      if ::Less.const_defined? :Engine
        @engine = ::Less::Engine.new(data)
      else
        parser  = ::Less::Parser.new(:filename => eval_file, :line => line)
        @engine = parser.parse(data)
      end
    end

    def evaluate(scope, locals, &block)
      @output ||= @engine.to_css
    end
  end
end

Version data entries

129 entries across 112 versions & 18 rubygems

Version Path
challah-0.3.5 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.3.4 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.3.3 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.3.2 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.3.1 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.3.0 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.2.1 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
challah-0.2.0 vendor/bundle/gems/tilt-1.3.3/lib/tilt/css.rb
tilt-1.3.3 lib/tilt/css.rb