4
5
6
7
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
|
# File 'lib/blue/template.rb', line 4
def self.included(klass)
klass.class_eval do
def local_template_dir
@local_template_dir ||= Pathname.new(Blue.rails_current + '/app/manifests/templates')
end
def local_template(pathname)
(local_template_dir + pathname.basename).expand_path
end
def template(pathname, b = binding)
pathname = Pathname.new(pathname) unless pathname.kind_of?(Pathname)
pathname = if local_template(pathname).exist?
local_template(pathname)
elsif pathname.exist?
pathname
else
raise LoadError, "Can't find template #{pathname}"
end
erb = ERB.new(pathname.read)
erb.filename = pathname.to_s
erb.result(b)
end
end
end
|