doc/classes/AssetHatHelper.html in asset_hat-0.4.1 vs doc/classes/AssetHatHelper.html in asset_hat-0.4.2
- old
+ new
@@ -83,11 +83,11 @@
</div>
<div class='source'>
<a class='source-toggle' href='#' onclick="toggleCode('M000032-source'); return false">
[show source]
</a>
- <pre id='M000032-source'> <span class="ruby-comment cmt"># File lib/asset_hat_helper.rb, line 368</span>
368: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">asset_path</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">source</span>)
369: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
370: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:css</span> ; <span class="ruby-identifier">stylesheet_path</span>(<span class="ruby-identifier">source</span>)
371: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:js</span> ; <span class="ruby-identifier">javascript_path</span>(<span class="ruby-identifier">source</span>)
372: <span class="ruby-keyword kw">else</span>
373: <span class="ruby-identifier">raise</span> <span class="ruby-node">%{Unknown type "#{type}"; should be one of: #{TYPES.join(', ')}.}</span>
374: <span class="ruby-keyword kw">end</span>
375: <span class="ruby-keyword kw">end</span></pre>
+ <pre id='M000032-source'> <span class="ruby-comment cmt"># File lib/asset_hat_helper.rb, line 363</span>
363: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">asset_path</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">source</span>)
364: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_sym</span>
365: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:css</span> ; <span class="ruby-identifier">stylesheet_path</span>(<span class="ruby-identifier">source</span>)
366: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:js</span> ; <span class="ruby-identifier">javascript_path</span>(<span class="ruby-identifier">source</span>)
367: <span class="ruby-keyword kw">else</span>
368: <span class="ruby-identifier">raise</span> <span class="ruby-node">%{
369: Unknown type "#{type}"; should be one of:
370: #{AssetHat::TYPES.join(', ')}.
371: }</span>.<span class="ruby-identifier">squish!</span>
372: <span class="ruby-keyword kw">end</span>
373: <span class="ruby-keyword kw">end</span></pre>
</div>
</div>
<div class='method public-instance' id='method-M000030'>
<a name='M000030'></a>
<div class='synopsis'>
@@ -146,11 +146,11 @@
</div>
<div class='source'>
<a class='source-toggle' href='#' onclick="toggleCode('M000030-source'); return false">
[show source]
</a>
- <pre id='M000030-source'> <span class="ruby-comment cmt"># File lib/asset_hat_helper.rb, line 159</span>
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include_css</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
160: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">blank?</span>
161: 
162: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span> <span class="ruby-operator">||=</span> {}
163: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>] <span class="ruby-operator">||=</span> {}
164: 
165: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
166: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys!</span>.<span class="ruby-identifier">reverse_merge!</span>(
167: <span class="ruby-identifier">:media</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'screen,projection'</span>, <span class="ruby-identifier">:ssl</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">ssl?</span>)
168: <span class="ruby-identifier">cache_key</span> = (<span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">options</span>]).<span class="ruby-identifier">inspect</span>
169: 
170: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">cache?</span> <span class="ruby-operator">||</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>][<span class="ruby-identifier">cache_key</span>].<span class="ruby-identifier">blank?</span>
171: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
172: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ssl</span>] <span class="ruby-operator">&&=</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">ssl_asset_host_differs?</span>
173: <span class="ruby-identifier">html</span> = <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>][<span class="ruby-identifier">cache_key</span>] =
174: <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:css</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">options</span>]))
175: <span class="ruby-keyword kw">end</span>
176: 
177: <span class="ruby-identifier">html</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>][<span class="ruby-identifier">cache_key</span>]
178: <span class="ruby-identifier">html</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:html_safe</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">html</span>.<span class="ruby-identifier">html_safe</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">html</span>
179: <span class="ruby-keyword kw">end</span></pre>
+ <pre id='M000030-source'> <span class="ruby-comment cmt"># File lib/asset_hat_helper.rb, line 159</span>
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include_css</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
160: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">blank?</span>
161: 
162: <span class="ruby-identifier">initialize_html_cache</span> <span class="ruby-identifier">:css</span>
163: 
164: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">setup_options</span>(<span class="ruby-identifier">args</span>,
165: <span class="ruby-identifier">:media</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'screen,projection'</span>,
166: <span class="ruby-identifier">:ssl</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">ssl?</span>
167: )
168: <span class="ruby-identifier">cache_key</span> = <span class="ruby-identifier">setup_cache_key</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
169: 
170: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">asset_cached?</span>(<span class="ruby-identifier">:css</span>, <span class="ruby-identifier">cache_key</span>)
171: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
172: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ssl</span>] <span class="ruby-operator">&&=</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">ssl_asset_host_differs?</span>
173: <span class="ruby-identifier">html</span> = <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>][<span class="ruby-identifier">cache_key</span>] =
174: <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:css</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">options</span>]))
175: <span class="ruby-keyword kw">end</span>
176: 
177: <span class="ruby-identifier">html</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>][<span class="ruby-identifier">cache_key</span>]
178: <span class="ruby-identifier">make_html_safe</span> <span class="ruby-identifier">html</span>
179: <span class="ruby-keyword kw">end</span></pre>
</div>
</div>
<div class='method public-instance' id='method-M000031'>
<a name='M000031'></a>
<div class='synopsis'>
@@ -172,11 +172,11 @@
</p>
<pre>include_js 'application.js'
=> <script src="/javascripts/application.js" type="text/javascript"></script></pre>
<p>
Include jQuery:
</p>
- <pre># Development/test environment:
include_js :jquery
=> <script src="/javascripts/jquery-VERSION.min.js" ...></script>

# Staging/production environment:
include_js :jquery
=> <script src="http://ajax.googleapis.com/.../jquery.min.js" ...></script>
 # Set jQuery versions either in `config/assets.yml`, or by using
 # `include_js :jquery, :version => '1.6.0'`.</pre>
+ <pre># Development/test environment:
include_js :jquery
=> <script src="/javascripts/jquery-VERSION.min.js" ...></script>

# Staging/production environment:
include_js :jquery
=> <script src="http://ajax.googleapis.com/.../jquery.min.js" ...></script>
 # Set jQuery versions either in `config/assets.yml`, or by using
 # `include_js :jquery, :version => '1.6.1'`.</pre>
<p>
Include a bundle of JS files (i.e., a concatenated set of files; configure
in <tt>config/assets.yml</tt>):
</p>
<pre>include_js :bundle => 'application'
=> <script src="/javascripts/bundles/application.min.js" ...></script></pre>
@@ -222,10 +222,10 @@
</div>
<div class='source'>
<a class='source-toggle' href='#' onclick="toggleCode('M000031-source'); return false">
[show source]
</a>
- <pre id='M000031-source'> <span class="ruby-comment cmt"># File lib/asset_hat_helper.rb, line 295</span>
295: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include_js</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
296: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">blank?</span>
297: 
298: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span> <span class="ruby-operator">||=</span> {}
299: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>] <span class="ruby-operator">||=</span> {}
300: 
301: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
302: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys!</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:ssl</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">ssl?</span>)
303: <span class="ruby-identifier">cache_key</span> = (<span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">options</span>]).<span class="ruby-identifier">inspect</span>
304: 
305: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">cache?</span> <span class="ruby-operator">||</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>][<span class="ruby-identifier">cache_key</span>].<span class="ruby-identifier">blank?</span>
306: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
307: 
308: <span class="ruby-identifier">htmls</span> = []
309: <span class="ruby-identifier">include_assets_options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">except</span>(<span class="ruby-identifier">:ssl</span>, <span class="ruby-identifier">:version</span>)
310: <span class="ruby-identifier">loader</span> = <span class="ruby-keyword kw">nil</span>
311: 
312: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:loader</span>].<span class="ruby-identifier">present?</span>
313: <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:loader</span>)
314: <span class="ruby-identifier">include_assets_options</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">:only_url</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>)
315: <span class="ruby-keyword kw">end</span>
316: 
317: <span class="ruby-comment cmt"># Get vendor HTML/URLs</span>
318: <span class="ruby-identifier">included_vendors</span> = (<span class="ruby-identifier">args</span> <span class="ruby-operator">&</span> <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">VENDORS</span>)
319: 
320: <span class="ruby-comment cmt"># Add HTML inclusions for vendors</span>
321: <span class="ruby-identifier">included_vendors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">vendor</span><span class="ruby-operator">|</span>
322: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">vendor</span>
323: <span class="ruby-identifier">src</span> = <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">Vendors</span>.<span class="ruby-identifier">source_for</span>(
324: <span class="ruby-identifier">vendor</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-identifier">:ssl</span>, <span class="ruby-identifier">:version</span>))
325: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:js</span>, <span class="ruby-identifier">src</span>,
326: <span class="ruby-identifier">include_assets_options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:cache</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>).
327: <span class="ruby-identifier">except</span>(<span class="ruby-identifier">:bundle</span>, <span class="ruby-identifier">:bundles</span>))
328: <span class="ruby-keyword kw">end</span>
329: 
330: <span class="ruby-comment cmt"># Get non-vendor HTML/URLs</span>
331: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:js</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">include_assets_options</span>]))
332: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">reject!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">:blank?</span>)
333: 
334: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">loader</span>
335: <span class="ruby-comment cmt"># `htmls` actually contains URLs; convert to an HTML/JS block</span>
336: <span class="ruby-identifier">urls</span> = <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">flatten</span>
337: <span class="ruby-identifier">htmls</span> = []
338: 
339: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">loader</span>
340: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:lab_js</span>
341: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">include_js</span>(<span class="ruby-identifier">:lab_js</span>)
342: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'<script type="text/javascript">'</span>
343: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">Vendors</span>.<span class="ruby-identifier">loader_js</span>(<span class="ruby-identifier">:lab_js</span>, <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">urls</span>)
344: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'</script>'</span>
345: <span class="ruby-keyword kw">end</span>
346: <span class="ruby-keyword kw">end</span>
347: 
348: <span class="ruby-comment cmt"># Convert to a URL (string), array of URLs, or one long HTML string</span>
349: <span class="ruby-identifier">html</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only_url</span>]
350: <span class="ruby-comment cmt"># Return one URL (string) or multiple (array of strings).</span>
351: <span class="ruby-comment cmt"># Not actually HTML.</span>
352: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">flatten!</span>
353: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">htmls</span>
354: <span class="ruby-keyword kw">else</span>
355: <span class="ruby-comment cmt"># Return one long string of HTML</span>
356: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>).<span class="ruby-identifier">strip</span>
357: <span class="ruby-keyword kw">end</span>
358: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>][<span class="ruby-identifier">cache_key</span>] = <span class="ruby-identifier">html</span>
359: <span class="ruby-keyword kw">end</span>
360: 
361: <span class="ruby-identifier">html</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>][<span class="ruby-identifier">cache_key</span>]
362: <span class="ruby-identifier">html</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:html_safe</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">html</span>.<span class="ruby-identifier">html_safe</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">html</span>
363: <span class="ruby-keyword kw">end</span></pre>
+ <pre id='M000031-source'> <span class="ruby-comment cmt"># File lib/asset_hat_helper.rb, line 295</span>
295: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include_js</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
296: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">blank?</span>
297: 
298: <span class="ruby-identifier">initialize_html_cache</span> <span class="ruby-identifier">:js</span>
299: 
300: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">setup_options</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">:ssl</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">ssl?</span>)
301: <span class="ruby-identifier">cache_key</span> = <span class="ruby-identifier">setup_cache_key</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
302: 
303: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">asset_cached?</span>(<span class="ruby-identifier">:js</span>, <span class="ruby-identifier">cache_key</span>)
304: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
305: 
306: <span class="ruby-identifier">htmls</span> = []
307: <span class="ruby-identifier">include_assets_options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">except</span>(<span class="ruby-identifier">:ssl</span>, <span class="ruby-identifier">:version</span>)
308: 
309: <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:loader</span>)
310: <span class="ruby-identifier">include_assets_options</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">:only_url</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">loader</span>
311: 
312: <span class="ruby-comment cmt"># Get vendor HTML/URLs</span>
313: <span class="ruby-identifier">included_vendors</span> = (<span class="ruby-identifier">args</span> <span class="ruby-operator">&</span> <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">VENDORS</span>)
314: 
315: <span class="ruby-comment cmt"># Add HTML inclusions for vendors</span>
316: <span class="ruby-identifier">included_vendors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">vendor</span><span class="ruby-operator">|</span>
317: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">vendor</span>
318: <span class="ruby-identifier">src</span> = <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">Vendors</span>.<span class="ruby-identifier">source_for</span>(
319: <span class="ruby-identifier">vendor</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-identifier">:ssl</span>, <span class="ruby-identifier">:version</span>))
320: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:js</span>, <span class="ruby-identifier">src</span>,
321: <span class="ruby-identifier">include_assets_options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:cache</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>).
322: <span class="ruby-identifier">except</span>(<span class="ruby-identifier">:bundle</span>, <span class="ruby-identifier">:bundles</span>))
323: <span class="ruby-keyword kw">end</span>
324: 
325: <span class="ruby-comment cmt"># Get non-vendor HTML/URLs</span>
326: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:js</span>, <span class="ruby-operator">*</span>(<span class="ruby-identifier">args</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">include_assets_options</span>]))
327: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">reject!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">:blank?</span>)
328: 
329: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">loader</span>
330: <span class="ruby-comment cmt"># `htmls` actually contains URLs; convert to an HTML/JS block</span>
331: <span class="ruby-identifier">urls</span> = <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">flatten</span>
332: <span class="ruby-identifier">htmls</span> = []
333: 
334: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">loader</span>
335: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:lab_js</span>
336: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">include_js</span>(<span class="ruby-identifier">:lab_js</span>)
337: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'<script type="text/javascript">'</span>
338: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">AssetHat</span><span class="ruby-operator">::</span><span class="ruby-constant">JS</span><span class="ruby-operator">::</span><span class="ruby-constant">Vendors</span>.<span class="ruby-identifier">loader_js</span>(<span class="ruby-identifier">:lab_js</span>, <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">urls</span>)
339: <span class="ruby-identifier">htmls</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'</script>'</span>
340: <span class="ruby-keyword kw">end</span>
341: <span class="ruby-keyword kw">end</span>
342: 
343: <span class="ruby-comment cmt"># Convert to a URL (string), array of URLs, or one long HTML string</span>
344: <span class="ruby-identifier">html</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only_url</span>]
345: <span class="ruby-comment cmt"># Return one URL (string) or multiple (array of strings).</span>
346: <span class="ruby-comment cmt"># Not actually HTML.</span>
347: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">flatten!</span>
348: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">htmls</span>
349: <span class="ruby-keyword kw">else</span>
350: <span class="ruby-comment cmt"># Return one long string of HTML</span>
351: <span class="ruby-identifier">htmls</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>).<span class="ruby-identifier">strip</span>
352: <span class="ruby-keyword kw">end</span>
353: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>][<span class="ruby-identifier">cache_key</span>] = <span class="ruby-identifier">html</span>
354: <span class="ruby-keyword kw">end</span>
355: 
356: <span class="ruby-identifier">html</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>][<span class="ruby-identifier">cache_key</span>]
357: <span class="ruby-identifier">make_html_safe</span> <span class="ruby-identifier">html</span>
358: <span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
</div>
</div>