Class: Distil::JavascriptFile

Inherits:
SourceFile show all
Defined in:
lib/distil/source-file/javascript-file.rb

Direct Known Subclasses

JsonFile

Instance Attribute Summary

Attributes inherited from SourceFile

#full_path, #parent_folder

Instance Method Summary collapse

Methods inherited from SourceFile

#add_asset, #add_dependency, #assets, #basename, #content, #copy_to, #dependencies, #error, #file_path, #file_path=, file_types, from_path, inherited, #initialize, #last_modified, #load_content, #minified_content, path_relative_to_folder, #relative_to_file, #relative_to_folder, #to_s, #to_str, #warning

Methods included from ErrorReporter

#error, error, #ignore_warnings, #ignore_warnings=, #report, warning, #warning

Constructor Details

This class inherits a constructor from Distil::SourceFile

Instance Method Details

#can_embed_as_content(file) ⇒ Object



7
8
9
# File 'lib/distil/source-file/javascript-file.rb', line 7

def can_embed_as_content(file)
  [".css", ".html", ".json"].include?(file.extension)
end

#escape_embeded_content(content) ⇒ Object



11
12
13
# File 'lib/distil/source-file/javascript-file.rb', line 11

def escape_embeded_content(content)
  content.gsub("\\", "\\\\").gsub("\n", "\\n").gsub("\"", "\\\"").gsub("'", "\\\\'")
end