8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/box.rb', line 8
def self.inline_templates
prioritized_callers = caller_files.reverse
loop do
file = prioritized_callers.shift
begin
io = ::IO.respond_to?(:binread) ? ::IO.binread(file) : ::IO.read(file)
app, @data = io.gsub("\r\n", "\n").split(/^__END__$/, 2)
rescue Errno::ENOENT
app, @data = nil
end
break if @data || prioritized_callers.empty?
end
if @data
file_names = @data.scan(/^@@\s*(\S*)\s*$/).flatten
file_contents = @data.split(/\n^@@.*$\n/)
file_contents.shift
end
unless file_names.nil?
Hash[file_names.zip(file_contents)]
else
{}
end
end
|