Class: Frozen::Template::Javascript
- Defined in:
- lib/frozen/template/javascript.rb
Instance Attribute Summary collapse
-
#file_load_path ⇒ Object
Returns the value of attribute file_load_path.
-
#options ⇒ Object
Returns the value of attribute options.
Attributes inherited from Base
#file_path, #template_root_path
Instance Method Summary collapse
- #build_extension ⇒ Object
- #build_path ⇒ Object
- #contents ⇒ Object
-
#initialize(options = {}) ⇒ Javascript
constructor
A new instance of Javascript.
- #read_from_file(file) ⇒ Object
- #render ⇒ Object
Methods inherited from Base
#build_file_path, #build_filename, #file_type, #relative_path, #relative_to_root, #render_to_file, #template_filename, #template_path
Constructor Details
#initialize(options = {}) ⇒ Javascript
Returns a new instance of Javascript.
11 12 13 14 15 16 17 |
# File 'lib/frozen/template/javascript.rb', line 11 def initialize(={}) @options = { :style => :compressed, :format => nil, :load_path => nil }.merge() end |
Instance Attribute Details
#file_load_path ⇒ Object
Returns the value of attribute file_load_path.
9 10 11 |
# File 'lib/frozen/template/javascript.rb', line 9 def file_load_path @file_load_path end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/frozen/template/javascript.rb', line 8 def @options end |
Instance Method Details
#build_extension ⇒ Object
28 29 30 |
# File 'lib/frozen/template/javascript.rb', line 28 def build_extension ".js" end |
#build_path ⇒ Object
32 33 34 |
# File 'lib/frozen/template/javascript.rb', line 32 def build_path "js" end |
#contents ⇒ Object
24 25 26 |
# File 'lib/frozen/template/javascript.rb', line 24 def contents read_from_file(file_path) end |
#read_from_file(file) ⇒ Object
19 20 21 22 |
# File 'lib/frozen/template/javascript.rb', line 19 def read_from_file(file) self.file_load_path = File.dirname(file) super(file) end |
#render ⇒ Object
36 37 38 39 40 41 |
# File 'lib/frozen/template/javascript.rb', line 36 def render js = "" js = CoffeeScript.compile(contents) if file_type == "coffee" js = contents if file_type == "js" Uglifier.new.compile(js) end |