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
    "    console.group(\"Compiling Error in file \#{path}\");\n    console.error(\#{str.to_json});\n    console.groupEnd();\n    JS\n  else\n    \"console.error(\#{str.to_json});\"\n  end\n\n  \"console.error(\#{str.to_json});alert(\#{str.inspect.to_json});\"\nend\n"

.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
  "    document.write(\"<script src='\#{path}?nodep'></script>\")\n  JS\nend\n"

.tag(path) ⇒ Object



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

def tag path
  "    <script src=\"\#{path}\" type=\"text/javascript\"></script>\n  HTML\nend\n"

Instance Method Details

#compileObject



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

def compile
  @file.text
end