Permalink
Browse files

fix #34

  • Loading branch information...
1 parent d52cc42 commit b7f131d8512569fc5b8a98ff1dc8b6fe95023d4c @tchak tchak committed Apr 19, 2012
Showing with 27 additions and 2 deletions.
  1. +5 −2 lib/ember/handlebars/template.rb
  2. +22 −0 test/hjstemplate_test.rb
@@ -31,10 +31,13 @@ def mustache_to_handlebars(scope, template)
end
def template_path(path)
- path = path.split('/')
root = configuration.templates_root
- path.delete(root) unless root.blank?
+ unless root.blank?
+ path.gsub!(/^#{Regexp.quote(root)}\/?/, '')
+ end
+
+ path = path.split('/')
path.join(configuration.templates_path_separator)
end
View
@@ -12,6 +12,28 @@ class HomeControllerTest < ActionController::TestCase
class HjsTemplateTest < ActionController::IntegrationTest
+ test "should replace separators with templates_path_separator" do
+ t = Ember::Handlebars::Template.new {}
+ Rails.configuration.handlebars.templates_path_separator = '-'
+ path = t.send(:template_path, 'app/templates/example')
+ assert path == 'app-templates-example', path
+ end
+
+ test "should strip only first occurence of templates_root" do
+ t = Ember::Handlebars::Template.new {}
+ Rails.configuration.handlebars.templates_root = 'app'
+ Rails.configuration.handlebars.templates_path_separator = '/'
+ path = t.send(:template_path, 'app/templates/app/example')
+ assert path == 'templates/app/example', path
+ end
+
+ test "should strip templates_root with / in it" do
+ t = Ember::Handlebars::Template.new {}
+ Rails.configuration.handlebars.templates_root = 'app/templates'
+ path = t.send(:template_path, 'app/templates/app/example')
+ assert path == 'app/example', path
+ end
+
test "asset pipeline should serve template" do
get "/assets/templates/test.js"
assert_response :success

0 comments on commit b7f131d

Please sign in to comment.