50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/tags/layout.rb', line 50
def load_layout(layout_name)
return @@layout_cache[layout_name] if @@layout_cache[layout_name]
found_layout = nil
Dir.entries(layout_path).each do |f|
next unless File.file? File.join(
layout_path, f
)
next unless File.basename(f, '.*') == layout_name
if found_layout
raise LayoutError, "More than one layout named #{layout_name} found."
end
found_layout = File.join(layout_path, f)
end
if found_layout.nil?
raise LayoutError, "No layouts named #{layout_name} found."
end
layout = File.read(found_layout)
@@layout_cache[layout_name] =
Liquid::Template.parse(layout)
@@layout_cache[layout_name]
end
|