Class: MasterView::TemplateProcessing::Tag

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

Overview

Records information about an element in the document.

A Tag is constructed when the start tag of an element is encountered. It tracks the name of the tag along with any attributes and MasterView directives attached to this element which are invoked during the rendering processing.

– ISSUE: better name for this class would be Element or TemplateElement. Tag is something the element has (in addition to its attributes and content), it’s not what it is. [Deb 22-Sep-2006] ++

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directives, tag_name, attributes, mode_type, parent, prolog, renderer) ⇒ Tag

Returns a new instance of Tag.



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/masterview/parser.rb', line 196

def initialize(directives, tag_name, attributes, mode_type, parent, prolog, renderer)
  @tag_name = tag_name

  unless attributes.nil? or attributes.is_a?( CaseInsensitiveHash ) # not a CaseInsensitiveHash so make it one
    @attributes = CaseInsensitiveHash.new
    @attributes.replace(attributes) # copy values in
  else
    @attributes = attributes
  end

  @mode_type = mode_type
  @directives = directives
  @stag = []
  @content = []
  @etag = []
  @parent = parent
  @prolog = prolog
  @renderer = renderer
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def attributes
  @attributes
end

#contentObject

Returns the value of attribute content.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def content
  @content
end

#directivesObject

Returns the value of attribute directives.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def directives
  @directives
end

#etagObject

Returns the value of attribute etag.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def etag
  @etag
end

#mode_typeObject

Returns the value of attribute mode_type.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def mode_type
  @mode_type
end

#parentObject

Returns the value of attribute parent.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def parent
  @parent
end

#prologObject

Returns the value of attribute prolog.



195
196
197
# File 'lib/masterview/parser.rb', line 195

def prolog
  @prolog
end

#rendererObject

Returns the value of attribute renderer.



195
196
197
# File 'lib/masterview/parser.rb', line 195

def renderer
  @renderer
end

#stagObject

Returns the value of attribute stag.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def stag
  @stag
end

#tag_nameObject

Returns the value of attribute tag_name.



194
195
196
# File 'lib/masterview/parser.rb', line 194

def tag_name
  @tag_name
end

Instance Method Details

#create_context(values = {}) ⇒ Object

creates a tag context using tag itself and mode type, also merge in any additional values passed in via values hash



218
219
220
221
222
223
# File 'lib/masterview/parser.rb', line 218

def create_context( values = {} )
  {
    :tag => self,
    :mode_type => @mode_type
  }.merge!(values)
end

#dataObject



225
226
227
# File 'lib/masterview/parser.rb', line 225

def data
  [] << @stag << @content << @etag
end