Module: HandlebarsAssets

Defined in:
lib/handlebars_assets.rb,
lib/handlebars_assets/config.rb,
lib/handlebars_assets/engine.rb,
lib/handlebars_assets/version.rb,
lib/handlebars_assets/handlebars.rb,
lib/handlebars_assets/handlebars_template.rb

Defined Under Namespace

Modules: Config, Unindent Classes: Engine, Handlebars, HandlebarsProcessor, HandlebarsRenderer, HandlebarsTemplate, NoOpEngine

Constant Summary collapse

PATH =
File.expand_path('../../vendor/assets/javascripts', __FILE__)
VERSION =
"0.23.9"

Class Method Summary collapse

Class Method Details

.add_to_asset_versioning(sprockets_environment) ⇒ Object


46
47
48
# File 'lib/handlebars_assets.rb', line 46

def self.add_to_asset_versioning(sprockets_environment)
  sprockets_environment.version += "-#{HandlebarsAssets::VERSION}"
end

.configure {|Config| ... } ⇒ Object

Yields:


15
16
17
# File 'lib/handlebars_assets.rb', line 15

def self.configure
  yield Config
end

.pathObject


11
12
13
# File 'lib/handlebars_assets.rb', line 11

def self.path
  PATH
end

.register_extensions(sprockets_environment) ⇒ Object


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
# File 'lib/handlebars_assets.rb', line 19

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
    if Config.haml_enabled? && Config.haml_available?
      Config.hamlbars_extensions.each do |ext|
        sprockets_environment.register_engine(ext, HandlebarsTemplate)
      end
    end
    if Config.slim_enabled? && Config.slim_available?
      Config.slimbars_extensions.each do |ext|
        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