Skip to content

Commit

Permalink
Updated to use the Ember codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
keithpitt committed Jan 3, 2012
1 parent 164c60f commit ac34352
Show file tree
Hide file tree
Showing 16 changed files with 8,898 additions and 23,877 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pkg/*
*.rbc
*.log
test/dummy/tmp
.DS_Store
6 changes: 3 additions & 3 deletions lib/ember-rails/hjs_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def prepare
end

# Generates Javascript code from a HandlebarsJS template.
# The SC template name is derived from the lowercase logical asset path
# The Ember template name is derived from the lowercase logical asset path
# by replacing non-alphanum characheters by underscores.
def evaluate(scope, locals, &block)
"SC.TEMPLATES[\"#{scope.logical_path}\"] = Handlebars.template(#{precompile(data)});\n"
"Ember.TEMPLATES[\"#{scope.logical_path}\"] = Handlebars.template(#{precompile(data)});\n"
end

private
Expand All @@ -34,7 +34,7 @@ def runtime
end

def ember
[ "sproutcore-precompiler.js", "sproutcore-core.js" ].map do |name|
[ "ember-precompiler.js", "ember.min.js" ].map do |name|
File.read(File.expand_path(File.join(__FILE__, "..", "..", "..", "vendor/assets/javascripts/#{name}")))
end.join("\n")
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ember-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module EmberRails
VERSION = "0.1.0"
VERSION = "0.2.0"
end
6 changes: 3 additions & 3 deletions test/hjstemplate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class HomeControllerTest < ActionController::TestCase
test "page header should include link to asset" do
get :index
assert_response :success
assert_select 'head script[type="text/javascript"][src="/assets/templates/test.js"]', true
assert_select 'head script[type="text/javascript"][src="/assets/templates/test.js"]', true, @response.body
end

end
Expand All @@ -15,13 +15,13 @@ class HjsTemplateTest < ActionController::IntegrationTest
test "asset pipeline should serve template" do
get "/assets/templates/test.js"
assert_response :success
assert @response.body == "SC.TEMPLATES[\"templates/test\"] = Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {\nhelpers = helpers || Handlebars.helpers;\n var buffer = '', stack1, stack2, stack3, stack4, tmp1, self=this, functionType=\"function\", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;\n\n\n stack1 = depth0;\n stack2 = \"test\";\n stack3 = {};\n stack4 = \"true\";\n stack3['escaped'] = stack4;\n stack4 = helpers.bind || SC.get(depth0, \"bind\");\n tmp1 = {};\n tmp1.hash = stack3;\n tmp1.contexts = [];\n tmp1.contexts.push(stack1);\n tmp1.data = data;\n if(typeof stack4 === functionType) { stack1 = stack4.call(depth0, stack2, tmp1); }\n else if(stack4=== undef) { stack1 = helperMissing.call(depth0, \"bind\", stack2, tmp1); }\n else { stack1 = stack4; }\n data.buffer.push(escapeExpression(stack1) + \"\\n\");\n return buffer;\n});\n"
assert @response.body == "Ember.TEMPLATES[\"templates/test\"] = Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {\nhelpers = helpers || Ember.Handlebars.helpers;\n var buffer = '', stack1, stack2, stack3, stack4, tmp1, self=this, functionType=\"function\", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;\n\n\n stack1 = depth0;\n stack2 = \"test\";\n stack3 = {};\n stack4 = \"true\";\n stack3['escaped'] = stack4;\n stack4 = helpers.bind || depth0.bind;\n tmp1 = {};\n tmp1.hash = stack3;\n tmp1.contexts = [];\n tmp1.contexts.push(stack1);\n tmp1.data = data;\n if(typeof stack4 === functionType) { stack1 = stack4.call(depth0, stack2, tmp1); }\n else if(stack4=== undef) { stack1 = helperMissing.call(depth0, \"bind\", stack2, tmp1); }\n else { stack1 = stack4; }\n data.buffer.push(escapeExpression(stack1) + \"\\n\");\n return buffer;\n});\n", @response.body.inspect
end

test "ensure new lines inside the anon function are persisted" do
get "/assets/templates/new_lines.js"
assert_response :success
assert @response.body.include?("helpers['if']\n")
assert @response.body.include?("helpers['if'];\n"), @response.body.inspect
end

end
Binary file added vendor/assets/javascripts/.DS_Store
Binary file not shown.
Loading

0 comments on commit ac34352

Please sign in to comment.