Class: Less::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/less/parser.rb

Overview

Convert lesscss source into an abstract syntax Tree

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Parser

Construct and configure new Less::Parser

Parameters:

  • opts (Hash)

    configuration options



21
22
23
24
# File 'lib/less/parser.rb', line 21

def initialize(options = {})
  @options = Less.defaults.merge(options)
  @context = self.class.backend.compile(compiler_source)
end

Class Method Details

.backendObject



7
8
9
10
11
12
13
# File 'lib/less/parser.rb', line 7

def backend
  @backend ||= ExecJS::ExternalRuntime.new(
    :name        => 'Node.js (V8)',
    :command     => ["nodejs", "node"],
    :runner_path => File.expand_path("../runner.js", __FILE__)
  )
end

Instance Method Details

#parse(less) ⇒ Less::Tree

Convert less source into a abstract syntaxt tree

Parameters:

  • less (String)

    the source to parse

Returns:



29
30
31
# File 'lib/less/parser.rb', line 29

def parse(less)
  Tree.new(less, @context, @options)
end