Class: Massimo::Javascript

Inherits:
Resource show all
Defined in:
lib/massimo/javascript.rb

Instance Attribute Summary

Attributes inherited from Resource

#content, #source_path

Instance Method Summary collapse

Methods inherited from Resource

all, #extensions, #filename, find, #initialize, #output_path, path, #process, processable?, resource_name, url, #url

Constructor Details

This class inherits a constructor from Massimo::Resource

Instance Method Details

#extensionObject



6
7
8
9
10
11
12
# File 'lib/massimo/javascript.rb', line 6

def extension
  if Tilt.registered?(super[1..-1])
    '.js'
  else
    super
  end
end

#renderObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/massimo/javascript.rb', line 14

def render
  if source_path.extname == '.js'
    options = Massimo.config.options_for(:sprockets).merge(
      :assert_root  => Massimo.config.output_path,
      :source_files => [ source_path.to_s ]
    )
    secretary = Sprockets::Secretary.new(options)
    secretary.install_assets
    @content = secretary.concatenation.to_s
  end
  super
end