Class: Tzispa::Rig::ParserNext
- Inherits:
-
Object
- Object
- Tzispa::Rig::ParserNext
- Includes:
- Syntax
- Defined in:
- lib/tzispa/rig/parsernext.rb
Constant Summary collapse
- EMPTY_STRING =
''
Constants included from Syntax
Syntax::RIG_EMPTY, Syntax::RIG_EXPRESSIONS, Syntax::RIG_STATEMENTS, Syntax::RIG_TEMPLATES, Syntax::RIG_URL_BUILDER
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#the_parsed ⇒ Object
readonly
Returns the value of attribute the_parsed.
Instance Method Summary collapse
- #attribute_tags ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(template, text = nil) ⇒ ParserNext
constructor
A new instance of ParserNext.
- #loop_parser(id) ⇒ Object
- #parse! ⇒ Object
- #render(binder, context = nil) ⇒ Object
Constructor Details
#initialize(template, text = nil) ⇒ ParserNext
Returns a new instance of ParserNext.
346 347 348 349 350 |
# File 'lib/tzispa/rig/parsernext.rb', line 346 def initialize(template, text=nil) @template = template @inner_text = text ? text : template.content @the_parsed = Array.new end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
344 345 346 |
# File 'lib/tzispa/rig/parsernext.rb', line 344 def flags @flags end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
344 345 346 |
# File 'lib/tzispa/rig/parsernext.rb', line 344 def template @template end |
#the_parsed ⇒ Object (readonly)
Returns the value of attribute the_parsed.
344 345 346 |
# File 'lib/tzispa/rig/parsernext.rb', line 344 def the_parsed @the_parsed end |
Instance Method Details
#attribute_tags ⇒ Object
376 377 378 379 380 381 382 |
# File 'lib/tzispa/rig/parsernext.rb', line 376 def @attribute_tags ||= @the_parsed.map { |p| p.id.to_sym if p.respond_to? :id }.concat(@the_parsed.map{ |p| p. if p.type==:ife }).compact.flatten.uniq.freeze end |
#empty? ⇒ Boolean
352 353 354 |
# File 'lib/tzispa/rig/parsernext.rb', line 352 def empty? @the_parsed.empty? end |
#loop_parser(id) ⇒ Object
384 385 386 387 388 |
# File 'lib/tzispa/rig/parsernext.rb', line 384 def loop_parser(id) @the_parsed.select{ |p| p.type==:loop && p.id==id}.concat( @the_parsed.select{ |p| p.type==:ife }.map { |p| p.loop_parser(id) }.flatten.compact ) end |
#parse! ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/tzispa/rig/parsernext.rb', line 356 def parse! @tags = nil parse_flags if @template.bindable? parse_statements parse_expressions end parse_url_builder parse_templates self end |
#render(binder, context = nil) ⇒ Object
368 369 370 371 372 373 374 |
# File 'lib/tzispa/rig/parsernext.rb', line 368 def render(binder, context=nil) @inner_text.dup.tap { |text| @the_parsed.each { |value| text.gsub! value.anchor, value.render(binder) } }.freeze end |