Module: Card::Set::Abstract::Script::JsFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb
Instance Method Summary collapse
-
#comment_with_source(js) ⇒ Object
-
#compress(input) ⇒ Object
-
#compress? ⇒ Boolean
-
#compression_error_message(e) ⇒ Object
-
#try_compress(input) ⇒ Object
-
#view: compressed ⇒ Object
Instance Method Details
#comment_with_source(js) ⇒ Object
21 22 23 |
# File 'platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb', line 21 def comment_with_source js "// #{card.name}\n#{js}" end |
#compress(input) ⇒ Object
25 26 27 |
# File 'platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb', line 25 def compress input compress? ? try_compress(input) : input end |
#compress? ⇒ Boolean
47 48 49 |
# File 'platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb', line 47 def compress? Cardio.config.compress_assets end |
#compression_error_message(e) ⇒ Object
39 40 41 42 43 44 45 |
# File 'platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb', line 39 def e if Card::Error.current Card::Error.current. else "JavaScript::SyntaxError (#{name}): #{e.}" end end |
#try_compress(input) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb', line 29 def try_compress input Uglifier.new(harmony: true).compile(input) rescue StandardError => e # CoffeeScript is compiled in a view # If there is a CoffeeScript syntax error we get the rescued view here # and the error that the rescued view is no valid Javascript # To get the original error we have to refer to Card::Error.current raise Card::Error, (e) end |
#view: compressed ⇒ Object
16 17 18 19 |
# File 'platypus/tmp/set/gem-defaults/mod019-script/abstract/00_script.rb', line 16 view :compressed do js = compress(_render_core) comment_with_source js end |