Module: Lipsiadmin::Utils::Literal

Defined in:
lib/utils/literal.rb

Overview

Returns an object whose to_json evaluates to code. Use this to pass a literal JavaScript expression as an argument to another JavaScriptGenerator method.

Examples:

  "function() { alert('test') }".to_l

Instance Method Summary collapse

Instance Method Details

#to_literalObject Also known as: to_l

Returns an object whose to_json evaluates to code. Use this to pass a literal JavaScript expression as an argument to another JavaScriptGenerator method.



14
15
16
# File 'lib/utils/literal.rb', line 14

def to_literal
  ActiveSupport::JSON::Variable.new(self.to_s)
end