Class: Less::Parser
- Inherits:
-
Object
- Object
- Less::Parser
- Defined in:
- lib/less/parser.rb
Overview
Convert lesscss source into an abstract syntax Tree
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
Construct and configure new Less::Parser.
-
#parse(less, options = {}) ⇒ Less::Tree
Convert ‘less` source into a abstract syntaxt tree.
Constructor Details
#initialize(options = {}) ⇒ Parser
Construct and configure new Less::Parser
20 21 22 23 |
# File 'lib/less/parser.rb', line 20 def initialize( = {}) = Less.defaults.merge() @context = self.class.backend.compile(compiler_source) end |
Class Method Details
.backend ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/less/parser.rb', line 5 def backend @backend ||= ExecJS::ExternalRuntime.new( name: 'Node.js (V8)', command: %w(nodejs node), runner_path: File.('../runner.js', __FILE__) ) end |
Instance Method Details
#parse(less, options = {}) ⇒ Less::Tree
Convert ‘less` source into a abstract syntaxt tree
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/less/parser.rb', line 29 def parse(less, = {}) old_node_env = ENV['NODE_PATH'] opts = .merge() if opts[:custom_functions] ENV['NODE_PATH'] = "#{opts[:custom_functions].dirname}:#{old_node_env}" opts[:custom_functions] = opts[:custom_functions].to_s.split('/').last end Result.new @context.call('render', less, opts) rescue ExecJS::ProgramError => e raise ParseError.new(e.) ensure ENV['NODE_PATH'] = old_node_env end |