Class: Apotomo::JavascriptGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/apotomo/javascript_generator.rb

Defined Under Namespace

Modules: Jquery, Prototype, Right

Constant Summary

JS_ESCAPER =
Object.new.extend(::ActionView::Helpers::JavaScriptHelper)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (JavascriptGenerator) initialize(framework)

Returns a new instance of JavascriptGenerator



5
6
7
8
# File 'lib/apotomo/javascript_generator.rb', line 5

def initialize(framework)
  raise "No JS framework specified" if framework.blank?
  extend "apotomo/javascript_generator/#{framework}".camelize.constantize
end

Class Method Details

+ (Object) escape(javascript)

Escape carrier returns and single and double quotes for JavaScript segments.



17
18
19
# File 'lib/apotomo/javascript_generator.rb', line 17

def self.escape(javascript)
  JS_ESCAPER.escape_javascript(javascript)
end

Instance Method Details

- (Object) <<(javascript)



10
11
12
# File 'lib/apotomo/javascript_generator.rb', line 10

def <<(javascript)
  "#{javascript}"
end

- (Object) escape(javascript)



21
22
23
# File 'lib/apotomo/javascript_generator.rb', line 21

def escape(javascript)
  self.class.escape(javascript)
end