Class: MasterView::TemplateProcessing::RenderMode

Inherits:
Object
  • Object
show all
Defined in:
lib/masterview/parser.rb

Overview

contains tags and output, each output style

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = nil, mode_type = :normal) ⇒ RenderMode



21
22
23
24
25
# File 'lib/masterview/parser.rb', line 21

def initialize(output = nil, mode_type = :normal)
  @output = output
  @tags = []
  @mode_type = mode_type
end

Instance Attribute Details

#mode_typeObject

Returns the value of attribute mode_type.



20
21
22
# File 'lib/masterview/parser.rb', line 20

def mode_type
  @mode_type
end

#outputObject

Returns the value of attribute output.



20
21
22
# File 'lib/masterview/parser.rb', line 20

def output
  @output
end

#tagsObject

Returns the value of attribute tags.



20
21
22
# File 'lib/masterview/parser.rb', line 20

def tags
  @tags
end

Instance Method Details

#determine_method(modifier, tag_name, base) ⇒ Object



58
59
60
# File 'lib/masterview/parser.rb', line 58

def determine_method(modifier, tag_name, base)
  type = "#{modifier.to_s}_#{tag_name.to_s}_#{base.to_s}"
end

#directivesObject



31
32
33
# File 'lib/masterview/parser.rb', line 31

def directives
  @tags.last.directives
end

#render_directives(method_name, context = tag.create_context) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/masterview/parser.rb', line 35

def render_directives(method_name, context=tag.create_context)
  dcs = DirectiveCallStack.new
  tag_name = tag.tag_name.downcase
  depth = tags.size-1
  @tags.each do |tag|
    case depth
    when 0
      dcs << tag.directives.determine_dcs(method_name)
    when 1
      dcs << tag.directives.determine_dcs(determine_method(:child, tag_name, method_name))
      dcs << tag.directives.determine_dcs(determine_method(:child, :any, method_name))
      dcs << tag.directives.determine_dcs(determine_method(:descendant, tag_name, method_name))
      dcs << tag.directives.determine_dcs(determine_method(:descendant, :any, method_name))
    else
      dcs << tag.directives.determine_dcs(determine_method(:descendant, tag_name, method_name))
      dcs << tag.directives.determine_dcs(determine_method(:descendant, :any, method_name))
    end
    depth -= 1
  end
  dcs.context = context
  dcs.render
end

#tagObject



27
28
29
# File 'lib/masterview/parser.rb', line 27

def tag
  @tags.last
end