Class: Distil::JavascriptProduct
- Inherits:
-
JavascriptBaseProduct
- Object
- Configurable
- Product
- JavascriptBaseProduct
- Distil::JavascriptProduct
- Includes:
- Concatenated
- Defined in:
- lib/distil/product/javascript-product.rb
Instance Attribute Summary
Attributes inherited from Product
#assets, #join_string, #target
Attributes inherited from Configurable
Instance Method Summary collapse
- #after_externals(f) ⇒ Object
- #after_files(f) ⇒ Object
-
#before_externals(f) ⇒ Object
def initialize(settings, target) super(settings, target) @options.global_export=target.name if true==global_export end.
- #before_files(f) ⇒ Object
Methods included from Concatenated
#after_file, #before_file, #external_files, #filename, #write_output
Methods inherited from JavascriptBaseProduct
#bootstrap_source, #can_embed_file?, #copy_bootstrap_script, #initialize
Methods inherited from Product
#can_embed_file?, #filename, #files, #files=, #handles_file?, #initialize, #relative_path, #up_to_date, #write_output
Methods inherited from Configurable
#get_option, #get_options, #initialize, option
Constructor Details
This class inherits a constructor from Distil::JavascriptBaseProduct
Instance Method Details
#after_externals(f) ⇒ Object
22 23 |
# File 'lib/distil/product/javascript-product.rb', line 22 def after_externals(f) end |
#after_files(f) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/distil/product/javascript-product.rb', line 65 def after_files(f) if global_export exports= ["window.#{global_export}={}", *additional_globals].join(", ") f.puts "})(#{exports});" end f.puts "\n\n/*#nocode-*/\n\n" f.puts "distil.kick();" if bootstrap end |
#before_externals(f) ⇒ Object
def initialize(settings, target)
super(settings, target)
@options.global_export=target.name if true==global_export
end
17 18 19 20 |
# File 'lib/distil/product/javascript-product.rb', line 17 def before_externals(f) f.puts("/*#nocode+*/") f.puts(bootstrap_source) if bootstrap end |
#before_files(f) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/distil/product/javascript-product.rb', line 25 def before_files(f) if 0 != assets.length asset_references= [] asset_map= [] assets.each { |a| if (a) content= target.get_content_for_file(a) content= content.gsub("\\", "\\\\").gsub("\n", "\\n").gsub("\"", "\\\"").gsub("'", "\\\\'") asset_references << "\"#{target.alias_for_asset(a)}\": \"#{content}\"" else asset_alias= target.alias_for_asset(a) asset_path= relative_path(a) next if asset_alias==asset_path asset_map << "'#{asset_alias}': '#{asset_path}'" end } f << <<-EOS distil.module('#{target.name}', { folder: '', asset_map: { #{asset_map.join(",\n ")} }, assets: { #{asset_references.join(",\n ")} } }); EOS end if global_export exports= [global_export, *additional_globals].join(", ") f.puts "(function(#{exports}){" end end |