Class: Less::Node::Mixin::Def
Instance Attribute Summary collapse
Attributes inherited from Element
#file, #imported, #name, #rules, #selector, #set
Attributes included from Entity
#parent
Instance Method Summary
collapse
Methods inherited from Element
#<<, #==, #[], #class?, #descend, #each, #elements, #empty?, #eql?, #equiv?, #first, #group, #id?, #identifiers, #last, #leaf?, #mixins, #nearest, #parameters, #properties, #root?, #tag?, #universal?
Methods included from Entity
#path, #root
Constructor Details
#initialize(name, params = []) ⇒ Def
Returns a new instance of Def.
237
238
239
240
241
242
|
# File 'lib/less/engine/nodes/element.rb', line 237
def initialize name, params = []
super name
@params = params.each do |param|
param.parent = self
end
end
|
Instance Attribute Details
Returns the value of attribute params.
235
236
237
|
# File 'lib/less/engine/nodes/element.rb', line 235
def params
@params
end
|
Instance Method Details
#call(args = []) ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/less/engine/nodes/element.rb', line 244
def call args = []
if e = @rules.find {|r| r.is_a? Element }
raise CompileError, "#{e} in #{self.inspect}: can't nest selectors inside a dynamic mixin."
end
env = Element.new
@params.zip(args).each do |param, val|
env << (val ? Variable.new(param.to_s, Expression.new([val])) : param)
end
to_css([], env)
end
|
271
272
273
|
# File 'lib/less/engine/nodes/element.rb', line 271
def inspect
".#{name}()"
end
|
#to_css(path, env) ⇒ Object
275
276
277
|
# File 'lib/less/engine/nodes/element.rb', line 275
def to_css path, env
super(path, env)
end
|
267
268
269
|
# File 'lib/less/engine/nodes/element.rb', line 267
def to_s
'.' + name
end
|
#variables ⇒ Object
263
264
265
|
# File 'lib/less/engine/nodes/element.rb', line 263
def variables
params + super
end
|