22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/madride/context.rb', line 22
def evaluate(path, options = {}, &block)
pathname = resolve(path)
attributes = environment.attributes_for(pathname)
processors = options[:processors] || attributes.processors
if options[:data]
result = options[:data]
else
if environment.respond_to?(:default_external_encoding)
mime_type = environment.mime_types(pathname.extname)
encoding = environment.encoding_for_mime_type(mime_type)
result = Sprockets::Utils.read_unicode(pathname, encoding)
else
result = Sprockets::Utils.read_unicode(pathname)
end
end
processors.each do |processor|
begin
template = processor.new(pathname.to_s) { result }
result = template.render(self, locals){ options[:yield] }
rescue Exception => e
annotate_exception! e
raise
end
end
if @layout
begin
layout = self.class.new(environment, @layout, resolve(@layout))
result = layout.evaluate(@layout, :yield => result)
rescue Exception => e
annotate_exception! e
raise
end
end
result
end
|