Skip to content

Commit

Permalink
change how sprocket registers, we need an engine
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRiedler committed Sep 21, 2013
1 parent 6ff4c2f commit 78064e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
17 changes: 7 additions & 10 deletions lib/handlebars_assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ def self.path
PATH
end

def register_extensions(sprockets_environment)
sprockets_environment.register_engine('.hbs', TiltHandlebars)
sprockets_environment.register_engine('.handlebars', TiltHandlebars)
sprockets_environment.register_engine('.hamlbars', TiltHandlebars) if HandlebarsAssets::Config.haml_available?
sprockets_environment.register_engine('.slimbars', TiltHandlebars) if HandlebarsAssets::Config.slim_available?
def self.register_extensions(sprockets_environment)
Sprockets.register_engine('.hbs', TiltHandlebars)
Sprockets.register_engine('.handlebars', TiltHandlebars)
Sprockets.register_engine('.hamlbars', TiltHandlebars) if HandlebarsAssets::Config.haml_available?

This comment has been minimized.

Copy link
@jimsynz

jimsynz Oct 1, 2013

Looks like this is the cause of #85 - why does handlebars assets need to register extensions that it knows nothing about - unless there's code here somewhere that hooks into the Hamlbars gem directly?

This comment has been minimized.

Copy link
@AlexRiedler

AlexRiedler Oct 1, 2013

Author Collaborator

This branch is a work in progress from a weekend or so ago; I will be changing how this section of the code works (will work off configuration instead). As thus, you will be able to register the default extensions (by doing nothing); or register only the extensions you indicate by specifying them.

The existing code is kinda ignorant to your environment currently in that respect, but I will try to get ontop of it ASAP (was doing for my own reasons, but if there is others that need this, then it is probably a good time to rush it forward a bit).

Sprockets.register_engine('.slimbars', TiltHandlebars) if HandlebarsAssets::Config.slim_available?
end

autoload(:Config, 'handlebars_assets/config')
autoload(:Handlebars, 'handlebars_assets/handlebars')
autoload(:TiltHandlebars, 'handlebars_assets/tilt_handlebars')
end

if defined?(Rails)
require 'handlebar_assets/railtie'
else
register_extensions(Sprockets)
end
HandlebarsAssets.register_extensions(Sprockets)
require 'handlebars_assets/engine' if defined?(Rails)
5 changes: 5 additions & 0 deletions lib/handlebars_assets/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module HandlebarsAssets
# NOTE: must be an engine because we are including assets in the gem
class Engine < ::Rails::Engine
end
end
7 changes: 0 additions & 7 deletions lib/handlebars_assets/railtie.rb

This file was deleted.

0 comments on commit 78064e1

Please sign in to comment.