Class: Deplate::Define::Element

Inherits:
Element
  • Object
show all
Defined in:
lib/deplate/define.rb

Instance Method Summary collapse

Methods inherited from Element

#join_lines, #join_lines_re_zh_cn

Instance Method Details

#finishObject



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/deplate/define.rb', line 168

def finish
    m = self.class.match(@accum.join(' '))
    if m
        m.captures.each_with_index do |e, i|
            @args[(i + 1).to_s] = e
        end
        @expected = Deplate::Element
        tmpl = Deplate::Template.new(:template  => self.class.tpl,
                                     :source    => @source,
                                     :container => self)
        Deplate::Define.let_variables(@deplate, @args) do
            @accum = tmpl.fill_in(@deplate, :source => @source)
        end
        @accum.flatten!
        @accum.collect! {|l| l.split("\n")}
        @accum.flatten!
    else
        raise 'Internal error!'
    end
    @elt = @deplate.parsed_array_from_strings(@accum, @source.begin, @source.file)
    return @elt
end