Class: Nitro::SharedMorpher

Inherits:
Morpher
  • Object
show all
Includes:
JavascriptUtils
Defined in:
lib/nitro/helper/javascript/morphing.rb

Overview

– A useful superclass for morphers. Provides easy access to js/css shared buffers. ++

Instance Method Summary collapse

Methods inherited from Morpher

#after_end, #after_start, #before_end, #before_start, #initialize

Constructor Details

This class inherits a constructor from Nitro::Morpher

Instance Method Details

#record_css(css) ⇒ Object Also known as: css

Record css to be injected in the template.



26
27
28
# File 'lib/nitro/helper/javascript/morphing.rb', line 26

def record_css(css)
  (@compiler.shared[:css_buffer] ||= '') << css
end

#record_js(code) ⇒ Object Also known as: js

Record javascript to be injected in the template.



19
20
21
# File 'lib/nitro/helper/javascript/morphing.rb', line 19

def record_js(code)
  (@compiler.shared[:js_buffer] ||= '') << code
end

#require_script_file(*names) ⇒ Object Also known as: add_script_file

Require javascript files.



33
34
35
36
37
38
# File 'lib/nitro/helper/javascript/morphing.rb', line 33

def require_script_file(*names)
  files = (@compiler.shared[:js_required_files] ||= Dictionary.new)
  for name in names
    files[name] = true    
  end
end