Class: Assette::Reader::Js

Inherits:
Object
  • Object
show all
Defined in:
lib/assette/readers/js.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.comment_strObject



23
24
25
# File 'lib/assette/readers/js.rb', line 23

def comment_str
  '// %s'
end

.error(str, path = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/assette/readers/js.rb', line 9

def error str, path=nil
  if path
    <<-JS
    console.group("Compiling Error in file #{path}");
    console.error(#{str.to_json});
    console.groupEnd();
    JS
  else
    "console.error(#{str.to_json});"
  end

  "console.error(#{str.to_json});alert(#{str.inspect.to_json});"
end

.include(path) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/assette/readers/js.rb', line 33

def include path
  # <<-JS
  #   (function() {
  #     var e = document.createElement('script'); e.async = false;
  #     e.src = '#{path}?nodep';
  #     document.getElementsByTagName('head')[0].appendChild(e);
  #   }());
  # JS
  <<-JS
    document.write("<script src='#{path}?nodep'></script>")
  JS
end

.tag(path) ⇒ Object



27
28
29
30
31
# File 'lib/assette/readers/js.rb', line 27

def tag path
  <<-HTML
    <script src="#{path}" type="text/javascript"></script>
  HTML
end

Instance Method Details

#compileObject



3
4
5
# File 'lib/assette/readers/js.rb', line 3

def compile
  @file.text
end