Class: Flex::Template::Partial

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/flex/template/partial.rb

Instance Attribute Summary

Attributes included from Common

#data, #name, #partials, #tags

Instance Method Summary collapse

Methods included from Common

#interpolate_partials, #setup

Constructor Details

#initialize(data) ⇒ Partial

Returns a new instance of Partial.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flex/template/partial.rb', line 7

def initialize(data)
  @data            = data
  tags             = Tags.new
  stringified      = tags.stringify(data)
  @partials, @tags = tags.partial_and_tag_names
  @tags_variables  = tags.variables
  instance_eval <<-ruby, __FILE__, __LINE__
    def interpolate(vars={}, partial_assigned_vars={})
      vars = Vars.new(vars, @tags_variables, partial_assigned_vars)
      vars = interpolate_partials(vars)
      #{stringified}
    end
  ruby
end

Instance Method Details

#to_sourceObject



22
23
24
# File 'lib/flex/template/partial.rb', line 22

def to_source
  {@name.to_s => @data}.to_yaml
end