Class: Amrita2::Filters::NVarForAttr

Inherits:
Base show all
Defined in:
lib/amrita2/template.rb

Instance Attribute Summary

Attributes inherited from Base

#next_

Instance Method Summary collapse

Methods inherited from Base

filter_method, inherited, #parse_filter_a, #|

Constructor Details

#initialize(*names) ⇒ NVarForAttr

Returns a new instance of NVarForAttr.



2403
2404
2405
# File 'lib/amrita2/template.rb', line 2403

def initialize(*names)
  @names = names
end

Instance Method Details

#element_render_code(de, cg, element, &block) ⇒ Object



2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
# File 'lib/amrita2/template.rb', line 2412

def element_render_code(de, cg, element, &block)
  if (element.name == 'span' && element.attributes.size == 0)
    yield
  else
    replace_args(element)
    if element.children.size > 0
      cg.put_string_expression(element.stag.output('').inspect.gsub(/\\#/, "#"))
      yield
      cg.put_constant(element.etag.output(''))
    else
      cg.put_string_expression(%["#{element.to_s}"])
    end
  end
end

#renderer_code(de, cg, element) ⇒ Object



2407
2408
2409
2410
# File 'lib/amrita2/template.rb', line 2407

def renderer_code(de, cg, element)
  make_tupple_code(cg) if @names.size > 0
  super
end