[DRE-commits] [ruby-handlebars-assets] 01/05: Imported Upstream version 0.23.0
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Mon Mar 7 09:01:48 UTC 2016
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository ruby-handlebars-assets.
commit 715f88b27ba6dafc422ecbdf583468c8e54ac65c
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Mon Mar 7 10:59:21 2016 +0530
Imported Upstream version 0.23.0
---
.gitignore | 1 +
Appraisals | 15 ++
CHANGELOG.md | 4 +
Rakefile | 4 +-
gemfiles/rails_4_1.gemfile | 8 +
gemfiles/rails_4_2.gemfile | 8 +
gemfiles/rails_5.gemfile | 8 +
gemfiles/sprockets_2.gemfile | 7 +
gemfiles/sprockets_3.gemfile | 7 +
gemfiles/tilt_1.gemfile | 7 +
gemfiles/tilt_2.gemfile | 7 +
handlebars_assets.gemspec | 9 +-
lib/handlebars_assets.rb | 15 +-
lib/handlebars_assets/engine.rb | 8 +-
lib/handlebars_assets/handlebars_template.rb | 99 +++++++--
lib/handlebars_assets/version.rb | 2 +-
metadata.yml | 207 -------------------
.../handlebars_assets/handlebars_processor_test.rb | 17 ++
test/handlebars_assets/shared/adapter_tests.rb | 199 ++++++++++++++++++
test/handlebars_assets/tilt_handlebars_test.rb | 226 +--------------------
vendor/assets/javascripts/handlebars.js | 40 ++--
vendor/assets/javascripts/handlebars.runtime.js | 25 +--
22 files changed, 434 insertions(+), 489 deletions(-)
diff --git a/.gitignore b/.gitignore
index 91e2b6a..e9f6489 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
.bundle
pkg/*
Gemfile.lock
+gemfiles/*.lock
diff --git a/Appraisals b/Appraisals
new file mode 100644
index 0000000..f7fc564
--- /dev/null
+++ b/Appraisals
@@ -0,0 +1,15 @@
+appraise "sprockets-3" do
+ gem "sprockets", "3.0.0"
+end
+
+appraise "sprockets-2" do
+ gem "sprockets", "2.3.3"
+end
+
+appraise "tilt-2" do
+ gem "tilt", "2.0.1"
+end
+
+appraise "tilt-1" do
+ gem "tilt", "1.4.1"
+end
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21235a8..daf8deb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.22.0 (2015-11-23)
+
+* Update Handlebars to v4.0.5
+
## 0.21.0 (2015-02-24)
* Update Handlebars to v4.0.2
diff --git a/Rakefile b/Rakefile
index 15940a3..f77e199 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,7 @@
+require "rubygems"
+require "bundler/setup"
require "bundler/gem_tasks"
-require 'rake/testtask'
+require "rake/testtask"
Rake::TestTask.new do |t|
t.libs << 'test'
diff --git a/gemfiles/rails_4_1.gemfile b/gemfiles/rails_4_1.gemfile
new file mode 100644
index 0000000..3a96594
--- /dev/null
+++ b/gemfiles/rails_4_1.gemfile
@@ -0,0 +1,8 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "rails", "4.1.14"
+gem "rails-sprockets", "2.3.3"
+
+gemspec :path => "../"
diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile
new file mode 100644
index 0000000..cc2618d
--- /dev/null
+++ b/gemfiles/rails_4_2.gemfile
@@ -0,0 +1,8 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "rails", "4.2.5"
+gem "rails-sprockets", "2.3.3"
+
+gemspec :path => "../"
diff --git a/gemfiles/rails_5.gemfile b/gemfiles/rails_5.gemfile
new file mode 100644
index 0000000..8285f70
--- /dev/null
+++ b/gemfiles/rails_5.gemfile
@@ -0,0 +1,8 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "rails", "5.0.0.beta1"
+gem "rails-sprockets", "3.0.0"
+
+gemspec :path => "../"
diff --git a/gemfiles/sprockets_2.gemfile b/gemfiles/sprockets_2.gemfile
new file mode 100644
index 0000000..e0f5788
--- /dev/null
+++ b/gemfiles/sprockets_2.gemfile
@@ -0,0 +1,7 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "sprockets", "2.3.3"
+
+gemspec :path => "../"
diff --git a/gemfiles/sprockets_3.gemfile b/gemfiles/sprockets_3.gemfile
new file mode 100644
index 0000000..52b0e11
--- /dev/null
+++ b/gemfiles/sprockets_3.gemfile
@@ -0,0 +1,7 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "sprockets", "3.0.0"
+
+gemspec :path => "../"
diff --git a/gemfiles/tilt_1.gemfile b/gemfiles/tilt_1.gemfile
new file mode 100644
index 0000000..2236fe6
--- /dev/null
+++ b/gemfiles/tilt_1.gemfile
@@ -0,0 +1,7 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "tilt", "1.4.1"
+
+gemspec :path => "../"
diff --git a/gemfiles/tilt_2.gemfile b/gemfiles/tilt_2.gemfile
new file mode 100644
index 0000000..8af0eca
--- /dev/null
+++ b/gemfiles/tilt_2.gemfile
@@ -0,0 +1,7 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "tilt", "2.0.1"
+
+gemspec :path => "../"
diff --git a/handlebars_assets.gemspec b/handlebars_assets.gemspec
index 1117bc1..3b63f27 100644
--- a/handlebars_assets.gemspec
+++ b/handlebars_assets.gemspec
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.email = ["leshill at gmail.com"]
s.homepage = "https://github.com/leshill/handlebars_assets"
s.summary = "Compile Handlebars templates in the Rails asset pipeline."
- s.description = "A Railities Gem to compile hbs assets"
+ s.description = "A Railties Gem to compile hbs assets"
s.rubyforge_project = "handlebars_assets"
@@ -20,15 +20,16 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.add_runtime_dependency "execjs", "~> 2.0"
- s.add_runtime_dependency "tilt", "~> 1.2"
+ s.add_runtime_dependency "tilt", ">= 1.2"
s.add_runtime_dependency "multi_json", "~> 1.0"
- s.add_runtime_dependency "sprockets", ">= 2.0.0", "< 4.0"
+ s.add_runtime_dependency "sprockets", ">= 2.0.0"
s.add_development_dependency "minitest", '~> 5.5'
s.add_development_dependency "haml", '~> 4.0'
s.add_development_dependency "rake", '~> 10.0'
s.add_development_dependency "slim", '~> 3.0'
- s.add_development_dependency 'json', '~> 1.7'
+ s.add_development_dependency "json", '~> 1.7'
+ s.add_development_dependency "appraisal"
s.post_install_message = "Remember to rake assets:clean or rake assets:purge on update! this is required because of handlebars updates"
end
diff --git a/lib/handlebars_assets.rb b/lib/handlebars_assets.rb
index 5580e21..2177dae 100644
--- a/lib/handlebars_assets.rb
+++ b/lib/handlebars_assets.rb
@@ -4,6 +4,7 @@ module HandlebarsAssets
autoload(:Config, 'handlebars_assets/config')
autoload(:Handlebars, 'handlebars_assets/handlebars')
autoload(:HandlebarsTemplate, 'handlebars_assets/handlebars_template')
+ autoload(:HandlebarsProcessor, 'handlebars_assets/handlebars_template')
PATH = File.expand_path('../../vendor/assets/javascripts', __FILE__)
@@ -16,6 +17,7 @@ module HandlebarsAssets
end
def self.register_extensions(sprockets_environment)
+ if Gem::Version.new(Sprockets::VERSION) < Gem::Version.new('3')
Config.handlebars_extensions.each do |ext|
sprockets_environment.register_engine(ext, HandlebarsTemplate)
end
@@ -29,12 +31,21 @@ module HandlebarsAssets
sprockets_environment.register_engine(ext, HandlebarsTemplate)
end
end
+ else
+ sprockets_environment.register_mime_type 'text/x-handlebars-template', extensions: Config.handlebars_extensions
+ if Config.slim_enabled? && Config.slim_available?
+ sprockets_environment.register_mime_type 'text/x-handlebars-template', extensions: Config.slimbars_extensions
+ end
+ if Config.haml_enabled? && Config.haml_available?
+ sprockets_environment.register_mime_type 'text/x-handlebars-template', extensions: Config.hamlbars_extensions
+ end
+ sprockets_environment.register_transformer 'text/x-handlebars-template', 'application/javascript', HandlebarsProcessor
+ end
end
def self.add_to_asset_versioning(sprockets_environment)
- sprockets_environment.config.version += "-#{HandlebarsAssets::VERSION}"
+ sprockets_environment.version += "-#{HandlebarsAssets::VERSION}"
end
-
end
# Register the engine (which will register extension in the app)
diff --git a/lib/handlebars_assets/engine.rb b/lib/handlebars_assets/engine.rb
index 8a4be6e..e1f8fa0 100644
--- a/lib/handlebars_assets/engine.rb
+++ b/lib/handlebars_assets/engine.rb
@@ -2,8 +2,12 @@ module HandlebarsAssets
# NOTE: must be an engine because we are including assets in the gem
class Engine < ::Rails::Engine
initializer "handlebars_assets.assets.register", :group => :all do |app|
- ::HandlebarsAssets::register_extensions(app.assets)
- app.assets.version += "#{::HandlebarsAssets::VERSION}"
+ config.assets.configure do |sprockets_env|
+ ::HandlebarsAssets::register_extensions(sprockets_env)
+ if Gem::Version.new(Sprockets::VERSION) < Gem::Version.new('3')
+ ::HandlebarsAssets::add_to_asset_versioning(sprockets_env)
+ end
+ end
end
end
end
diff --git a/lib/handlebars_assets/handlebars_template.rb b/lib/handlebars_assets/handlebars_template.rb
index c0fd0bd..17f2e83 100644
--- a/lib/handlebars_assets/handlebars_template.rb
+++ b/lib/handlebars_assets/handlebars_template.rb
@@ -12,15 +12,76 @@ module HandlebarsAssets
end
end
+ # Sprockets <= 3
class HandlebarsTemplate < Tilt::Template
-
- include Unindent
-
def self.default_mime_type
'application/javascript'
end
def initialize_engine
+ HandlebarsRenderer.initialize_engine
+ end
+
+ def prepare
+ @engine = renderer.choose_engine(data)
+ end
+
+ def evaluate(scope, locals, &block)
+ source = @engine.render(scope, locals, &block)
+ renderer.compile(source)
+ end
+
+ private
+
+ def renderer
+ @renderer ||= HandlebarsRenderer.new(path: @file)
+ end
+ end
+
+ # Sprockets 4
+ class HandlebarsProcessor
+
+ def self.instance
+ @instance ||= new
+ end
+
+ def self.call(input)
+ instance.call(input)
+ end
+
+ def self.cache_key
+ instance.cache_key
+ end
+
+ attr_reader :cache_key
+
+ def initialize(options = {})
+ @cache_key = [self.class.name, ::HandlebarsAssets::VERSION, options].freeze
+ end
+
+ def call(input)
+ renderer = HandlebarsRenderer.new(path: input[:filename])
+ engine = renderer.choose_engine(input[:data])
+ renderer.compile(engine.render)
+ end
+ end
+
+ class NoOpEngine
+ def initialize(data)
+ @data = data
+ end
+
+ def render(*args)
+ @data
+ end
+ end
+
+ class HandlebarsRenderer
+ include Unindent
+
+ def self.initialize_engine
+ return if @initialized
+
begin
require 'haml'
rescue LoadError
@@ -31,28 +92,26 @@ module HandlebarsAssets
rescue LoadError
# slim not available
end
+
+ @initialized = true
end
- def prepare
- @template_path = TemplatePath.new(@file)
- @engine =
- if @template_path.is_haml?
- Haml::Engine.new(data, HandlebarsAssets::Config.haml_options)
- elsif @template_path.is_slim?
- Slim::Template.new(HandlebarsAssets::Config.slim_options) { data }
- else
- nil
- end
+ def initialize(options)
+ self.class.initialize_engine
+ @template_path = TemplatePath.new(options[:path])
end
- def evaluate(scope, locals, &block)
- source =
- if @engine
- @engine.render(scope, locals, &block)
- else
- data
- end
+ def choose_engine(data)
+ if @template_path.is_haml?
+ Haml::Engine.new(data, HandlebarsAssets::Config.haml_options)
+ elsif @template_path.is_slim?
+ Slim::Template.new(HandlebarsAssets::Config.slim_options) { data }
+ else
+ NoOpEngine.new(data)
+ end
+ end
+ def compile(source)
# remove trailing \n on file, for some reason the directives pipeline adds this
source.chomp!($/)
diff --git a/lib/handlebars_assets/version.rb b/lib/handlebars_assets/version.rb
index ad54dce..3d0bee7 100644
--- a/lib/handlebars_assets/version.rb
+++ b/lib/handlebars_assets/version.rb
@@ -1,3 +1,3 @@
module HandlebarsAssets
- VERSION = "0.21.0"
+ VERSION = "0.23.0"
end
diff --git a/metadata.yml b/metadata.yml
deleted file mode 100644
index 8466a9c..0000000
--- a/metadata.yml
+++ /dev/null
@@ -1,207 +0,0 @@
---- !ruby/object:Gem::Specification
-name: handlebars_assets
-version: !ruby/object:Gem::Version
- version: 0.21.0
-platform: ruby
-authors:
-- Les Hill
-autorequire:
-bindir: bin
-cert_chain: []
-date: 2015-09-27 00:00:00.000000000 Z
-dependencies:
-- !ruby/object:Gem::Dependency
- name: execjs
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '2.0'
- type: :runtime
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '2.0'
-- !ruby/object:Gem::Dependency
- name: tilt
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.2'
- type: :runtime
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.2'
-- !ruby/object:Gem::Dependency
- name: multi_json
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.0'
- type: :runtime
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.0'
-- !ruby/object:Gem::Dependency
- name: sprockets
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 2.0.0
- - - "<"
- - !ruby/object:Gem::Version
- version: '4.0'
- type: :runtime
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 2.0.0
- - - "<"
- - !ruby/object:Gem::Version
- version: '4.0'
-- !ruby/object:Gem::Dependency
- name: minitest
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '5.5'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '5.5'
-- !ruby/object:Gem::Dependency
- name: haml
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '4.0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '4.0'
-- !ruby/object:Gem::Dependency
- name: rake
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '10.0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '10.0'
-- !ruby/object:Gem::Dependency
- name: slim
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '3.0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '3.0'
-- !ruby/object:Gem::Dependency
- name: json
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.7'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.7'
-description: A Railities Gem to compile hbs assets
-email:
-- leshill at gmail.com
-executables: []
-extensions: []
-extra_rdoc_files: []
-files:
-- ".gitignore"
-- ".ruby-gemset"
-- CHANGELOG.md
-- Gemfile
-- MIT-LICENSE
-- README.md
-- Rakefile
-- handlebars_assets.gemspec
-- lib/handlebars_assets.rb
-- lib/handlebars_assets/config.rb
-- lib/handlebars_assets/engine.rb
-- lib/handlebars_assets/handlebars.rb
-- lib/handlebars_assets/handlebars_template.rb
-- lib/handlebars_assets/version.rb
-- test/edge/handlebars.js
-- test/handlebars_assets/compiling_test.rb
-- test/handlebars_assets/hamlbars_test.rb
-- test/handlebars_assets/slimbars_test.rb
-- test/handlebars_assets/tilt_handlebars_test.rb
-- test/patch/patch.js
-- test/test_helper.rb
-- vendor/assets/javascripts/handlebars.js
-- vendor/assets/javascripts/handlebars.runtime.js
-homepage: https://github.com/leshill/handlebars_assets
-licenses:
-- MIT
-metadata: {}
-post_install_message: Remember to rake assets:clean or rake assets:purge on update!
- this is required because of handlebars updates
-rdoc_options: []
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
-requirements: []
-rubyforge_project: handlebars_assets
-rubygems_version: 2.2.2
-signing_key:
-specification_version: 4
-summary: Compile Handlebars templates in the Rails asset pipeline.
-test_files:
-- test/edge/handlebars.js
-- test/handlebars_assets/compiling_test.rb
-- test/handlebars_assets/hamlbars_test.rb
-- test/handlebars_assets/slimbars_test.rb
-- test/handlebars_assets/tilt_handlebars_test.rb
-- test/patch/patch.js
-- test/test_helper.rb
diff --git a/test/handlebars_assets/handlebars_processor_test.rb b/test/handlebars_assets/handlebars_processor_test.rb
new file mode 100644
index 0000000..c740ad5
--- /dev/null
+++ b/test/handlebars_assets/handlebars_processor_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+require_relative 'shared/adapter_tests'
+
+module HandlebarsAssets
+ class HandlebarsProcessorTest < Minitest::Test
+ include AdapterTests
+
+ def teardown
+ HandlebarsAssets::Config.reset!
+ HandlebarsAssets::Handlebars.reset!
+ end
+
+ def render_it(scope, source)
+ HandlebarsAssets::HandlebarsProcessor.call(filename: scope.pathname.to_s, data: source)
+ end
+ end
+end
diff --git a/test/handlebars_assets/shared/adapter_tests.rb b/test/handlebars_assets/shared/adapter_tests.rb
new file mode 100644
index 0000000..64f306f
--- /dev/null
+++ b/test/handlebars_assets/shared/adapter_tests.rb
@@ -0,0 +1,199 @@
+require 'test_helper'
+require 'haml'
+require 'slim'
+
+module AdapterTests
+ include CompilerSupport
+ include SprocketsScope
+
+ def compile_haml(source)
+ ::Haml::Engine.new(source, HandlebarsAssets::Config.haml_options).render
+ end
+
+ def compile_slim(source)
+ ::Slim::Template.new(HandlebarsAssets::Config.slim_options) { source }.render
+ end
+
+ def test_render
+ root = '/myapp/app/assets/templates'
+ file = 'test_render.hbs'
+ scope = make_scope root, file
+ source = "This is {{handlebars}}"
+
+ assert_equal hbs_compiled('test_render', source), render_it(scope, source)
+ end
+
+ # Sprockets does not add nested root paths (i.e.
+ # app/assets/javascripts/templates is rooted at app/assets/javascripts)
+ def test_template_misnaming
+ root = '/myapp/app/assets/javascripts'
+ file = 'templates/test_template_misnaming.hbs'
+ scope = make_scope root, file
+ source = "This is {{handlebars}}"
+
+ assert_equal hbs_compiled('test_template_misnaming', source), render_it(scope, source)
+ end
+
+ def test_path_prefix
+ root = '/myapp/app/assets/javascripts'
+ file = 'app/templates/test_path_prefix.hbs'
+ scope = make_scope root, file
+ source = "This is {{handlebars}}"
+
+ HandlebarsAssets::Config.path_prefix = 'app/templates'
+
+ assert_equal hbs_compiled('test_path_prefix', source), render_it(scope, source)
+ end
+
+ def test_underscore_partials
+ root = '/myapp/app/assets/javascripts'
+ file1 = 'app/templates/_test_underscore.hbs'
+ scope1 = make_scope root, file1
+ file2 = 'app/templates/some/thing/_test_underscore.hbs'
+ scope2 = make_scope root, file2
+ source = "This is {{handlebars}}"
+
+ HandlebarsAssets::Config.path_prefix = 'app/templates'
+
+ assert_equal hbs_compiled_partial('_test_underscore', source), render_it(scope1, source)
+
+ assert_equal hbs_compiled_partial('some/thing/_test_underscore', source), render_it(scope2, source)
+ end
+
+ def test_chomped_underscore_partials
+ assert_equal HandlebarsAssets::Config.chomp_underscore_for_partials?, false
+
+ HandlebarsAssets::Config.chomp_underscore_for_partials = true
+ assert_equal HandlebarsAssets::Config.chomp_underscore_for_partials?, true
+
+ root = '/myapp/app/assets/javascripts'
+ file1 = 'app/templates/_test_underscore.hbs'
+ scope1 = make_scope root, file1
+ file2 = 'app/templates/some/thing/_test_underscore.hbs'
+ scope2 = make_scope root, file2
+ source = "This is {{handlebars}}"
+
+ HandlebarsAssets::Config.path_prefix = 'app/templates'
+
+ assert_equal hbs_compiled_partial('test_underscore', source), render_it(scope1, source)
+
+ assert_equal hbs_compiled_partial('some/thing/test_underscore', source), render_it(scope2, source)
+
+ end
+
+ def test_without_known_helpers_opt
+ root = '/myapp/app/assets/templates'
+ file = 'test_without_known.hbs'
+ scope = make_scope root, file
+ source = "{{#with author}}By {{first_name}} {{last_name}}{{/with}}"
+
+ assert_equal hbs_compiled('test_without_known', source), render_it(scope, source)
+ end
+
+ def test_known_helpers_opt
+ root = '/myapp/app/assets/templates'
+ file = 'test_known.hbs'
+ scope = make_scope root, file
+ source = "{{#with author}}By {{first_name}} {{last_name}}{{/with}}"
+
+ HandlebarsAssets::Config.known_helpers_only = true
+
+ assert_equal hbs_compiled('test_known', source), render_it(scope, source)
+ end
+
+ def test_with_custom_helpers
+ root = '/myapp/app/assets/templates'
+ file = 'test_custom_helper.hbs'
+ scope = make_scope root, file
+ source = "{{#custom author}}By {{first_name}} {{last_name}}{{/custom}}"
+
+ assert_equal hbs_compiled('test_custom_helper', source), render_it(scope, source)
+ end
+
+ def test_with_custom_known_helpers
+ root = '/myapp/app/assets/templates'
+ file = 'test_custom_known_helper.hbs'
+ scope = make_scope root, file
+ source = "{{#custom author}}By {{first_name}} {{last_name}}{{/custom}}"
+
+ HandlebarsAssets::Config.known_helpers_only = true
+ HandlebarsAssets::Config.known_helpers = %w(custom)
+
+ assert_equal hbs_compiled('test_custom_known_helper', source), render_it(scope, source)
+ end
+
+ def test_template_namespace
+ root = '/myapp/app/assets/javascripts/templates'
+ file = 'test_template_namespace.hbs'
+ scope = make_scope root, file
+ source = "This is {{handlebars}}"
+
+ HandlebarsAssets::Config.template_namespace = 'JST'
+
+ assert_equal hbs_compiled('test_template_namespace', source), render_it(scope, source)
+ end
+
+ def test_ember_render
+ root = '/myapp/app/assets/templates'
+ file = 'test_render.hbs'
+ scope = make_scope root, file
+ source = "This is {{handlebars}}"
+
+ HandlebarsAssets::Config.ember = true
+ HandlebarsAssets::Config.multiple_frameworks = false
+
+ expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
+ assert_equal expected_compiled, render_it(scope, source)
+ end
+
+ def test_multiple_frameworks_with_ember_render
+ root = '/myapp/app/assets/templates'
+ non_ember = 'test_render.hbs'
+ non_ember_but_with_ember = 'test_member.hbs'
+ ember_ext_no_hbs = 'test_render.ember'
+ ember_ext = 'test_render.ember.hbs'
+ ember_with_haml = 'test_render.ember.hamlbars'
+ ember_with_slim = 'test_render.ember.slimbars'
+ ember_ext_with_erb = 'test_render.ember.hbs.erb'
+
+ HandlebarsAssets::Config.ember = true
+ HandlebarsAssets::Config.multiple_frameworks = true
+
+ # File without ember extension should compile to default namespace
+ scope = make_scope root, non_ember
+ source = "This is {{handlebars}}"
+ assert_equal hbs_compiled('test_render', source), render_it(scope, source)
+
+ # File without ember extension but with ember in it should compile to default namespace
+ scope = make_scope root, non_ember_but_with_ember
+ source = "This is {{handlebars}}"
+ assert_equal hbs_compiled('test_member', source), render_it(scope, source)
+
+ # File with ember extension should compile to ember specific namespace
+ expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
+ scope = make_scope root, ember_ext_no_hbs
+ assert_equal expected_compiled, render_it(scope, source)
+
+ # File with ember and erb extension should compile to ember specific namespace
+ expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
+ scope = make_scope root, ember_ext_with_erb
+ assert_equal expected_compiled, render_it(scope, source)
+
+ # File with ember.hbs extension should compile to ember specific namespace
+ expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
+ scope = make_scope root, ember_ext
+ assert_equal expected_compiled, render_it(scope, source)
+
+ # File with ember.hamlbars extension should compile to ember specific namespace
+ expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("<p>This is {{handlebars}}</p>");};
+ scope = make_scope root, ember_with_haml
+ source = "%p This is {{handlebars}}"
+ assert_equal expected_compiled, render_it(scope, source)
+
+ # File with ember.slimbars extension should compile to ember specific namespace
+ expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("<p>This is {{handlebars}}</p>");};
+ source = "p This is {{handlebars}}"
+ scope = make_scope root, ember_with_slim
+ assert_equal expected_compiled, render_it(scope, source)
+ end
+end
diff --git a/test/handlebars_assets/tilt_handlebars_test.rb b/test/handlebars_assets/tilt_handlebars_test.rb
index 57b4983..b700fcf 100644
--- a/test/handlebars_assets/tilt_handlebars_test.rb
+++ b/test/handlebars_assets/tilt_handlebars_test.rb
@@ -1,236 +1,18 @@
require 'test_helper'
+require_relative 'shared/adapter_tests'
module HandlebarsAssets
class HandlebarsTemplateTest < Minitest::Test
- include CompilerSupport
- include SprocketsScope
+ include AdapterTests
def teardown
HandlebarsAssets::Config.reset!
HandlebarsAssets::Handlebars.reset!
end
- def compile_haml(source)
- Haml::Engine.new(source, HandlebarsAssets::Config.haml_options).render
- end
-
- def compile_slim(source)
- Slim::Template.new(HandlebarsAssets::Config.slim_options) { source }.render
- end
-
- def test_render
- root = '/myapp/app/assets/templates'
- file = 'test_render.hbs'
- scope = make_scope root, file
- source = "This is {{handlebars}}"
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_render', source), template.render(scope, {})
- end
-
- # Sprockets does not add nested root paths (i.e.
- # app/assets/javascripts/templates is rooted at app/assets/javascripts)
- def test_template_misnaming
- root = '/myapp/app/assets/javascripts'
- file = 'templates/test_template_misnaming.hbs'
- scope = make_scope root, file
- source = "This is {{handlebars}}"
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_template_misnaming', source), template.render(scope, {})
- end
-
- def test_path_prefix
- root = '/myapp/app/assets/javascripts'
- file = 'app/templates/test_path_prefix.hbs'
- scope = make_scope root, file
- source = "This is {{handlebars}}"
-
- HandlebarsAssets::Config.path_prefix = 'app/templates'
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_path_prefix', source), template.render(scope, {})
- end
-
- def test_underscore_partials
- root = '/myapp/app/assets/javascripts'
- file1 = 'app/templates/_test_underscore.hbs'
- scope1 = make_scope root, file1
- file2 = 'app/templates/some/thing/_test_underscore.hbs'
- scope2 = make_scope root, file2
- source = "This is {{handlebars}}"
-
- HandlebarsAssets::Config.path_prefix = 'app/templates'
-
- template1 = HandlebarsAssets::HandlebarsTemplate.new(scope1.pathname.to_s) { source }
-
- assert_equal hbs_compiled_partial('_test_underscore', source), template1.render(scope1, {})
-
- template2 = HandlebarsAssets::HandlebarsTemplate.new(scope2.pathname.to_s) { source }
-
- assert_equal hbs_compiled_partial('some/thing/_test_underscore', source), template2.render(scope2, {})
- end
-
- def test_chomped_underscore_partials
- assert_equal HandlebarsAssets::Config.chomp_underscore_for_partials?, false
-
- HandlebarsAssets::Config.chomp_underscore_for_partials = true
- assert_equal HandlebarsAssets::Config.chomp_underscore_for_partials?, true
-
- root = '/myapp/app/assets/javascripts'
- file1 = 'app/templates/_test_underscore.hbs'
- scope1 = make_scope root, file1
- file2 = 'app/templates/some/thing/_test_underscore.hbs'
- scope2 = make_scope root, file2
- source = "This is {{handlebars}}"
-
- HandlebarsAssets::Config.path_prefix = 'app/templates'
-
- template1 = HandlebarsAssets::HandlebarsTemplate.new(scope1.pathname.to_s) { source }
-
- assert_equal hbs_compiled_partial('test_underscore', source), template1.render(scope1, {})
-
- template2 = HandlebarsAssets::HandlebarsTemplate.new(scope2.pathname.to_s) { source }
-
- assert_equal hbs_compiled_partial('some/thing/test_underscore', source), template2.render(scope2, {})
-
- end
-
- def test_without_known_helpers_opt
- root = '/myapp/app/assets/templates'
- file = 'test_without_known.hbs'
- scope = make_scope root, file
- source = "{{#with author}}By {{first_name}} {{last_name}}{{/with}}"
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_without_known', source), template.render(scope, {})
- end
-
- def test_known_helpers_opt
- root = '/myapp/app/assets/templates'
- file = 'test_known.hbs'
- scope = make_scope root, file
- source = "{{#with author}}By {{first_name}} {{last_name}}{{/with}}"
-
- HandlebarsAssets::Config.known_helpers_only = true
-
+ def render_it(scope, source)
template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_known', source), template.render(scope, {})
- end
-
- def test_with_custom_helpers
- root = '/myapp/app/assets/templates'
- file = 'test_custom_helper.hbs'
- scope = make_scope root, file
- source = "{{#custom author}}By {{first_name}} {{last_name}}{{/custom}}"
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_custom_helper', source), template.render(scope, {})
- end
-
- def test_with_custom_known_helpers
- root = '/myapp/app/assets/templates'
- file = 'test_custom_known_helper.hbs'
- scope = make_scope root, file
- source = "{{#custom author}}By {{first_name}} {{last_name}}{{/custom}}"
-
- HandlebarsAssets::Config.known_helpers_only = true
- HandlebarsAssets::Config.known_helpers = %w(custom)
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_custom_known_helper', source), template.render(scope, {})
- end
-
- def test_template_namespace
- root = '/myapp/app/assets/javascripts/templates'
- file = 'test_template_namespace.hbs'
- scope = make_scope root, file
- source = "This is {{handlebars}}"
-
- HandlebarsAssets::Config.template_namespace = 'JST'
-
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- assert_equal hbs_compiled('test_template_namespace', source), template.render(scope, {})
- end
-
- def test_ember_render
- root = '/myapp/app/assets/templates'
- file = 'test_render.hbs'
- scope = make_scope root, file
- source = "This is {{handlebars}}"
-
- HandlebarsAssets::Config.ember = true
- HandlebarsAssets::Config.multiple_frameworks = false
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
-
- expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
- assert_equal expected_compiled, template.render(scope, {})
- end
-
- def test_multiple_frameworks_with_ember_render
- root = '/myapp/app/assets/templates'
- non_ember = 'test_render.hbs'
- non_ember_but_with_ember = 'test_member.hbs'
- ember_ext_no_hbs = 'test_render.ember'
- ember_ext = 'test_render.ember.hbs'
- ember_with_haml = 'test_render.ember.hamlbars'
- ember_with_slim = 'test_render.ember.slimbars'
- ember_ext_with_erb = 'test_render.ember.hbs.erb'
-
- HandlebarsAssets::Config.ember = true
- HandlebarsAssets::Config.multiple_frameworks = true
-
- # File without ember extension should compile to default namespace
- scope = make_scope root, non_ember
- source = "This is {{handlebars}}"
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
- assert_equal hbs_compiled('test_render', source), template.render(scope, {})
-
- # File without ember extension but with ember in it should compile to default namespace
- scope = make_scope root, non_ember_but_with_ember
- source = "This is {{handlebars}}"
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
- assert_equal hbs_compiled('test_member', source), template.render(scope, {})
-
- # File with ember extension should compile to ember specific namespace
- expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
- scope = make_scope root, ember_ext_no_hbs
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
- assert_equal expected_compiled, template.render(scope, {})
-
- # File with ember and erb extension should compile to ember specific namespace
- expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
- scope = make_scope root, ember_ext_with_erb
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
- assert_equal expected_compiled, template.render(scope, {})
-
- # File with ember.hbs extension should compile to ember specific namespace
- expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("This is {{handlebars}}");};
- scope = make_scope root, ember_ext
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { source }
- assert_equal expected_compiled, template.render(scope, {})
-
- # File with ember.hamlbars extension should compile to ember specific namespace
- expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("<p>This is {{handlebars}}</p>");};
- scope = make_scope root, ember_with_haml
- source = "%p This is {{handlebars}}"
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { compile_haml(source) }
- assert_equal expected_compiled, template.render(scope, {})
-
- # File with ember.slimbars extension should compile to ember specific namespace
- expected_compiled = %{window.Ember.TEMPLATES["test_render"] = Ember.Handlebars.compile("<p>This is {{handlebars}}</p>");};
- source = "p This is {{handlebars}}"
- scope = make_scope root, ember_with_slim
- template = HandlebarsAssets::HandlebarsTemplate.new(scope.pathname.to_s) { compile_slim(source) }
- assert_equal expected_compiled, template.render(scope, {})
+ template.render(scope, {})
end
end
end
diff --git a/vendor/assets/javascripts/handlebars.js b/vendor/assets/javascripts/handlebars.js
index ebbf027..289ae45 100644
--- a/vendor/assets/javascripts/handlebars.js
+++ b/vendor/assets/javascripts/handlebars.js
@@ -1,6 +1,6 @@
/*!
- handlebars v4.0.2
+ handlebars v4.0.5
Copyright (C) 2011-2015 by Yehuda Katz
@@ -275,7 +275,7 @@ return /******/ (function(modules) { // webpackBootstrap
var _logger2 = _interopRequireDefault(_logger);
- var VERSION = '4.0.2';
+ var VERSION = '4.0.5';
exports.VERSION = VERSION;
var COMPILER_REVISION = 7;
@@ -327,7 +327,7 @@ return /******/ (function(modules) { // webpackBootstrap
_utils.extend(this.partials, name);
} else {
if (typeof partial === 'undefined') {
- throw new _exception2['default']('Attempting to register a partial as undefined');
+ throw new _exception2['default']('Attempting to register a partial called "' + name + '" as undefined');
}
this.partials[name] = partial;
}
@@ -663,12 +663,6 @@ return /******/ (function(modules) { // webpackBootstrap
}
function execIteration(field, index, last) {
- // Don't iterate over undefined values since we can't execute blocks against them
- // in non-strict (js) mode.
- if (context[field] == null) {
- return;
- }
-
if (data) {
data.key = field;
data.index = index;
@@ -689,7 +683,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (context && typeof context === 'object') {
if (_utils.isArray(context)) {
for (var j = context.length; i < j; i++) {
- execIteration(i, i, i === context.length - 1);
+ if (i in context) {
+ execIteration(i, i, i === context.length - 1);
+ }
}
} else {
var priorKey = undefined;
@@ -920,11 +916,14 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ },
/* 17 */
-/***/ function(module, exports) {
+/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
+
+ var _utils = __webpack_require__(5);
+
var logger = {
methodMap: ['debug', 'info', 'warn', 'error'],
level: 'info',
@@ -932,7 +931,7 @@ return /******/ (function(modules) { // webpackBootstrap
// Maps a given level value to the `methodMap` indexes above.
lookupLevel: function lookupLevel(level) {
if (typeof level === 'string') {
- var levelMap = logger.methodMap.indexOf(level.toLowerCase());
+ var levelMap = _utils.indexOf(logger.methodMap, level.toLowerCase());
if (levelMap >= 0) {
level = levelMap;
} else {
@@ -1238,6 +1237,7 @@ return /******/ (function(modules) { // webpackBootstrap
var partialBlock = undefined;
if (options.fn && options.fn !== noop) {
+ options.data = _base.createFrame(options.data);
partialBlock = options.data['partial-block'] = options.fn;
if (partialBlock.partials) {
@@ -1295,6 +1295,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (root.Handlebars === Handlebars) {
root.Handlebars = $Handlebars;
}
+ return Handlebars;
};
};
@@ -1399,7 +1400,8 @@ return /******/ (function(modules) { // webpackBootstrap
symbols_: { "error": 2, "root": 3, "program": 4, "EOF": 5, "program_repetition0": 6, "statement": 7, "mustache": 8, "block": 9, "rawBlock": 10, "partial": 11, "partialBlock": 12, "content": 13, "COMMENT": 14, "CONTENT": 15, "openRawBlock": 16, "rawBlock_repetition_plus0": 17, "END_RAW_BLOCK": 18, "OPEN_RAW_BLOCK": 19, "helperName": 20, "openRawBlock_repetition0": 21, "openRawBlock_option0": 22, "CLOSE_RAW_BLOCK": 23, "openBlock": 24, "block_option0": 25, "closeBlock": 26, "openI [...]
terminals_: { 2: "error", 5: "EOF", 14: "COMMENT", 15: "CONTENT", 18: "END_RAW_BLOCK", 19: "OPEN_RAW_BLOCK", 23: "CLOSE_RAW_BLOCK", 29: "OPEN_BLOCK", 33: "CLOSE", 34: "OPEN_INVERSE", 39: "OPEN_INVERSE_CHAIN", 44: "INVERSE", 47: "OPEN_ENDBLOCK", 48: "OPEN", 51: "OPEN_UNESCAPED", 54: "CLOSE_UNESCAPED", 55: "OPEN_PARTIAL", 60: "OPEN_PARTIAL_BLOCK", 65: "OPEN_SEXPR", 68: "CLOSE_SEXPR", 72: "ID", 73: "EQUALS", 75: "OPEN_BLOCK_PARAMS", 77: "CLOSE_BLOCK_PARAMS", 80: "STRING", 81: "NUMB [...]
productions_: [0, [3, 2], [4, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [13, 1], [10, 3], [16, 5], [9, 4], [9, 4], [24, 6], [27, 6], [38, 6], [43, 2], [45, 3], [45, 1], [26, 3], [8, 5], [8, 5], [11, 5], [12, 3], [59, 5], [63, 1], [63, 1], [64, 5], [69, 1], [71, 3], [74, 3], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [56, 1], [56, 1], [79, 2], [78, 1], [86, 3], [86, 1], [6, 0], [6, 2], [17, 1], [17, 2], [21, 0], [21, 2], [22, 0], [22, 1], [25 [...]
- performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
+ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$
+ /**/) {
var $0 = $$.length - 1;
switch (yystate) {
@@ -1936,7 +1938,8 @@ return /******/ (function(modules) { // webpackBootstrap
this.begin(condition);
} };
lexer.options = {};
- lexer.performAction = function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
+ lexer.performAction = function anonymous(yy, yy_, $avoiding_name_collisions, YY_START
+ /**/) {
function strip(start, end) {
return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng - end);
@@ -2103,7 +2106,7 @@ return /******/ (function(modules) { // webpackBootstrap
return 72;
break;
case 42:
- return 72;
+ yy_.yytext = yy_.yytext.replace(/\\([\\\]])/g, '$1');return 72;
break;
case 43:
return 'INVALID';
@@ -2113,7 +2116,7 @@ return /******/ (function(modules) { // webpackBootstrap
break;
}
};
- lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]*?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^( [...]
+ lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]*?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^( [...]
lexer.conditions = { "mu": { "rules": [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, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], "inclusive": false }, "emu": { "rules": [2], "inclusive": false }, "com": { "rules": [6], "inclusive": false }, "raw": { "rules": [3, 4, 5], "inclusive": false }, "INITIAL": { "rules": [0, 1, 44], "inclusive": true } };
return lexer;
})();
@@ -4296,13 +4299,14 @@ return /******/ (function(modules) { // webpackBootstrap
setupHelper: function setupHelper(paramSize, name, blockHelper) {
var params = [],
paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper);
- var foundHelper = this.nameLookup('helpers', name, 'helper');
+ var foundHelper = this.nameLookup('helpers', name, 'helper'),
+ callContext = this.aliasable(this.contextName(0) + ' != null ? ' + this.contextName(0) + ' : {}');
return {
params: params,
paramsInit: paramsInit,
name: foundHelper,
- callParams: [this.contextName(0)].concat(params)
+ callParams: [callContext].concat(params)
};
},
diff --git a/vendor/assets/javascripts/handlebars.runtime.js b/vendor/assets/javascripts/handlebars.runtime.js
index cd5a6bf..95049f3 100644
--- a/vendor/assets/javascripts/handlebars.runtime.js
+++ b/vendor/assets/javascripts/handlebars.runtime.js
@@ -1,6 +1,6 @@
/*!
- handlebars v4.0.2
+ handlebars v4.0.5
Copyright (C) 2011-2015 by Yehuda Katz
@@ -207,7 +207,7 @@ return /******/ (function(modules) { // webpackBootstrap
var _logger2 = _interopRequireDefault(_logger);
- var VERSION = '4.0.2';
+ var VERSION = '4.0.5';
exports.VERSION = VERSION;
var COMPILER_REVISION = 7;
@@ -259,7 +259,7 @@ return /******/ (function(modules) { // webpackBootstrap
_utils.extend(this.partials, name);
} else {
if (typeof partial === 'undefined') {
- throw new _exception2['default']('Attempting to register a partial as undefined');
+ throw new _exception2['default']('Attempting to register a partial called "' + name + '" as undefined');
}
this.partials[name] = partial;
}
@@ -595,12 +595,6 @@ return /******/ (function(modules) { // webpackBootstrap
}
function execIteration(field, index, last) {
- // Don't iterate over undefined values since we can't execute blocks against them
- // in non-strict (js) mode.
- if (context[field] == null) {
- return;
- }
-
if (data) {
data.key = field;
data.index = index;
@@ -621,7 +615,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (context && typeof context === 'object') {
if (_utils.isArray(context)) {
for (var j = context.length; i < j; i++) {
- execIteration(i, i, i === context.length - 1);
+ if (i in context) {
+ execIteration(i, i, i === context.length - 1);
+ }
}
} else {
var priorKey = undefined;
@@ -852,11 +848,14 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ },
/* 16 */
-/***/ function(module, exports) {
+/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
+
+ var _utils = __webpack_require__(4);
+
var logger = {
methodMap: ['debug', 'info', 'warn', 'error'],
level: 'info',
@@ -864,7 +863,7 @@ return /******/ (function(modules) { // webpackBootstrap
// Maps a given level value to the `methodMap` indexes above.
lookupLevel: function lookupLevel(level) {
if (typeof level === 'string') {
- var levelMap = logger.methodMap.indexOf(level.toLowerCase());
+ var levelMap = _utils.indexOf(logger.methodMap, level.toLowerCase());
if (levelMap >= 0) {
level = levelMap;
} else {
@@ -1170,6 +1169,7 @@ return /******/ (function(modules) { // webpackBootstrap
var partialBlock = undefined;
if (options.fn && options.fn !== noop) {
+ options.data = _base.createFrame(options.data);
partialBlock = options.data['partial-block'] = options.fn;
if (partialBlock.partials) {
@@ -1227,6 +1227,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (root.Handlebars === Handlebars) {
root.Handlebars = $Handlebars;
}
+ return Handlebars;
};
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-handlebars-assets.git
More information about the Pkg-ruby-extras-commits
mailing list