Sha256: ed26b1098a1684d145721979990b5d1bb10578dea7f9863b808596673ce3a5bf

Contents?: true

Size: 856 Bytes

Versions: 2

Compression:

Stored size: 856 Bytes

Contents

require 'malt/engines/abstract'

module Malt::Engine

  # LESS
  #
  #   http://lesscss.org/
  #
  # LESS is an extension of CSS. You can write LESS code just like you would write CSS,
  # except you need to compile it to CSS. That's what this class is for.
  class Less < Abstract

    default :less

    #
    def render(params)
      text = params[:text]
      into = params[:to]
      case into
      when :css, nil
        intermediate(params).to_css
      else
        super(params)
      end
    end

    #
    def intermediate(params)
      text = params[:text]
      ::Less::Engine.new(text)
    end

    #
    #def compile(text, file)
    #  intermediate # ??
    #end

    private

    # Load Less library if not already loaded.
    def initialize_engine
      return if defined? ::Less::Engine
      require_library 'less'
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
malt-0.3.0 lib/malt/engines/less.rb
malt-0.2.0 lib/malt/engines/less.rb