2009-04-05 00:13:08 -07:00
|
|
|
require File.join(File.dirname(__FILE__), 'functions')
|
2008-10-11 04:00:55 -07:00
|
|
|
module Sass
|
2008-10-12 19:03:06 -07:00
|
|
|
module Script
|
2008-10-12 19:04:40 -07:00
|
|
|
class Funcall # :nodoc:
|
2009-04-05 00:13:08 -07:00
|
|
|
class EvaluationContext # :nodoc:
|
|
|
|
|
|
|
|
include Sass::Script::Functions
|
|
|
|
|
|
|
|
attr_reader :options
|
|
|
|
|
|
|
|
def initialize(options)
|
|
|
|
@options = options
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-10-11 04:00:55 -07:00
|
|
|
attr_reader :name, :args
|
|
|
|
|
|
|
|
def initialize(name, args)
|
|
|
|
@name = name
|
|
|
|
@args = args
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
"#{name}(#{args.map {|a| a.inspect}.join(', ')})"
|
|
|
|
end
|
|
|
|
|
2008-10-12 20:26:56 -07:00
|
|
|
def perform(environment)
|
|
|
|
args = self.args.map {|a| a.perform(environment)}
|
2009-01-22 16:41:36 -08:00
|
|
|
unless Haml::Util.has?(:public_instance_method, Functions, name) && name !~ /^__/
|
2008-10-12 20:26:56 -07:00
|
|
|
return Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})")
|
2008-10-11 04:00:55 -07:00
|
|
|
end
|
|
|
|
|
2009-04-05 00:13:08 -07:00
|
|
|
return EvaluationContext.new(environment.options).send(name, *args)
|
2008-10-11 04:00:55 -07:00
|
|
|
rescue ArgumentError => e
|
2009-02-06 02:41:47 -08:00
|
|
|
raise e unless e.backtrace.first =~ /:in `(#{name}|perform)'$/
|
2008-10-11 04:00:55 -07:00
|
|
|
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|