Permalink
Browse files

finished up support for multiple-directories. See commit 6a15c7d

  • Loading branch information...
1 parent 0304be2 commit 896e5070971b43f66ac0b4c46c69b43ed3466d53 Conrad VanLandingham committed Aug 25, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/sinatra/ember.rb
View
@@ -8,11 +8,13 @@ def self.registered(app)
app.extend ClassMethods
end
- def self.template_path(path, file)
- unless root.blank?
+ def self.template_name(path, file)
+ unless path.empty?
file.gsub!(/^#{Regexp.quote(path)}\/?/, '')
end
+ file.slice!(/.(handlebars|hbs|hjs)/)
+
file
end
@@ -44,7 +46,7 @@ def ember_init!
templates = paths.map do |path, files|
files.map do |file|
content = File.read(file)
- "Ember.TEMPLATES[#{self.template_path(path,file)}] = Ember.Handlebars.compile(#{content.inspect});"
+ "Ember.TEMPLATES[#{Sinatra::Ember.template_name(path,file).inspect}] = Ember.Handlebars.compile(#{content.inspect});"
end
end
@@ -57,7 +59,7 @@ def ember_init!
output = output.strip.gsub(/^ {16}/, '')
# compute the maximum mtime for all paths
- mtime = paths.map do |path|
+ mtime = paths.flatten.map do |path|
if File.file?(path)
File.mtime(path).to_i
end

0 comments on commit 896e507

Please sign in to comment.