haml_coffee_assets 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -275,10 +275,10 @@ If you wish to put the templates in a different location, you may want to change
275
275
  config.hamlcoffee.name_filter = lambda { |n| n.sub /^templates\//, '' }
276
276
  ```
277
277
 
278
- By default, `name_filter` strips the leading `templates/` directory off of the name. Please note, `name_filter` is only
279
- applicable if you use the `.hamlc` extension and let Haml Coffee Assets handle the JST generation. If you use the
280
- `.jst.hamlc` extension, then Sprockets JST processor will name things accordingly (e.g., with `templates/` intact in
281
- this case).
278
+ By default, `name_filter` strips the leading `templates/` directory off of the name and also a leading `_` from the
279
+ template name. Please note, `name_filter` is only applicable if you use the `.hamlc` extension and let Haml Coffee
280
+ Assets handle the JST generation. If you use the `.jst.hamlc` extension, then Sprockets JST processor will name
281
+ things accordingly (e.g., with `templates/` intact in this case).
282
282
 
283
283
  The template name filter is not used with AMD loader.
284
284
 
@@ -0,0 +1,19 @@
1
+ require "action_view"
2
+
3
+ module HamlCoffeeAssets
4
+ module ActionView
5
+ # Custom resolver to prevent Haml Coffee templates from being rendered by
6
+ # Rails for non-HTML formats, since a template name without a MIME type
7
+ # in it would normally be a fallback for all formats.
8
+ #
9
+ class Resolver < ::ActionView::FileSystemResolver
10
+ def find_templates(name, prefix, partial, details)
11
+ if details[:formats].include?(:html)
12
+ super
13
+ else
14
+ []
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,7 @@
1
1
  # coding: UTF-8
2
2
 
3
+ require 'haml_coffee_assets/action_view/resolver'
4
+
3
5
  module HamlCoffeeAssets
4
6
  module Rails
5
7
 
@@ -10,11 +12,6 @@ module HamlCoffeeAssets
10
12
 
11
13
  config.hamlcoffee = ::HamlCoffeeAssets.config
12
14
 
13
- # Add shared template path to ActionView's load path
14
- config.before_configuration do |app|
15
- app.paths['app/views'] << config.hamlcoffee.shared_template_path
16
- end
17
-
18
15
  # Initialize Haml Coffee Assets after Sprockets
19
16
  #
20
17
  initializer 'sprockets.hamlcoffeeassets', :group => :all, :after => 'sprockets.environment' do |app|
@@ -25,6 +22,13 @@ module HamlCoffeeAssets
25
22
  ::ActionView::Template.register_template_handler(:hamlc, ::HamlCoffeeAssets::ActionView::TemplateHandler)
26
23
  end
27
24
 
25
+ # Add template path to ActionController's view paths.
26
+ ActiveSupport.on_load(:action_controller) do
27
+ path = ::HamlCoffeeAssets.config.shared_template_path
28
+ resolver = ::HamlCoffeeAssets::ActionView::Resolver.new(path)
29
+ ::ActionController::Base.append_view_path(resolver)
30
+ end
31
+
28
32
  next unless app.assets
29
33
 
30
34
  # Register Tilt template (for Sprockets)
@@ -1,5 +1,5 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  module HamlCoffeeAssets
4
- VERSION = '1.10.0' unless defined?(HamlCoffeeAssets::VERSION)
4
+ VERSION = '1.11.0' unless defined?(HamlCoffeeAssets::VERSION)
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_coffee_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-13 00:00:00.000000000 Z
12
+ date: 2013-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coffee-script
@@ -82,6 +82,7 @@ executables: []
82
82
  extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
+ - lib/haml_coffee_assets/action_view/resolver.rb
85
86
  - lib/haml_coffee_assets/action_view/template_handler.rb
86
87
  - lib/haml_coffee_assets/compiler.rb
87
88
  - lib/haml_coffee_assets/configuration.rb