Module: HamlCoffeeAssets

Defined in:
lib/haml_coffee_assets.rb,
lib/haml_coffee_assets/version.rb,
lib/haml_coffee_assets/compiler.rb,
lib/haml_coffee_assets/transformer.rb,
lib/haml_coffee_assets/rails/engine.rb,
lib/haml_coffee_assets/configuration.rb,
lib/haml_coffee_assets/global_context.rb,
lib/haml_coffee_assets/action_view/resolver.rb,
lib/haml_coffee_assets/action_view/template_handler.rb

Overview

Haml Coffee Assets main module

Defined Under Namespace

Modules: ActionView, Compiler, Rails Classes: Configuration, GlobalContext, Transformer

Constant Summary collapse

VERSION =
'1.27.0'

Class Method Summary collapse

Class Method Details

.configHamlCoffeeAssets::Configuration

Get the Haml Coffee Assets configuration

Returns:



7
8
9
# File 'lib/haml_coffee_assets/configuration.rb', line 7

def self.config
  @config ||= ::HamlCoffeeAssets::Configuration.new
end

.helpers(compile = true) ⇒ String

Get the Haml Coffee Assets helper file

Parameters:

  • compile (Boolean) (defaults to: true)

    whether to compile the CS helpers or not

Returns:

  • (String)

    the helpers content



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/haml_coffee_assets.rb', line 47

def self.helpers(compile=true)
  require 'erb'

  content = File.read(HamlCoffeeAssets.helpers_path)
  script = ERB.new(content).result(binding)

  if compile
    require 'coffee-script'
    script = CoffeeScript.compile(script)
  end

  script << GlobalContext.to_s if defined?(Rails)
  script
end

.helpers_pathString

Get the path to the ‘hamlcoffee.js.coffee.erb` helper file.

Returns:

  • (String)

    the absolute path to the helpers file



38
39
40
# File 'lib/haml_coffee_assets.rb', line 38

def self.helpers_path
  File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'assets', 'javascripts', 'hamlcoffee.js.coffee.erb'))
end