doc/classes/AssetHatHelper.html in asset_hat-0.2.1 vs doc/classes/AssetHatHelper.html in asset_hat-0.3.0
- old
+ new
@@ -45,12 +45,12 @@
</div>
<div id='method-list'>
<h2>Methods</h2>
<h3>public instance</h3>
<ol>
- <li><a href="#M000023">include_css</a></li>
- <li><a href="#M000024">include_js</a></li>
+ <li><a href="#M000027">include_css</a></li>
+ <li><a href="#M000028">include_js</a></li>
</ol>
</div>
<div id='section'>
<div id='constants-list'>
<h2>Constants</h2>
@@ -64,19 +64,19 @@
</table>
</div>
</div>
<div id='methods'>
<h2>Public instance methods</h2>
- <div class='method public-instance' id='method-M000023'>
- <a name='M000023'></a>
+ <div class='method public-instance' id='method-M000027'>
+ <a name='M000027'></a>
<div class='synopsis'>
<span class='name'>include_css</span>
<span class='arguments'>(*args)</span>
</div>
<div class='description'>
<p>
- <tt><a href="AssetHatHelper.html#M000023">include_css</a></tt> is a smart
+ <tt><a href="AssetHatHelper.html#M000027">include_css</a></tt> is a smart
wrapper for Rails’ <tt>stylesheet_link_tag</tt>. The two can be used
together while migrating to <a href="AssetHat.html">AssetHat</a>.
</p>
<p>
Include a single stylesheet:
@@ -93,27 +93,31 @@
<pre>include_css :bundle => 'application'
=> <link href="/stylesheets/bundles/application.min.css" ... /></pre>
<p>
Include multiple stylesheets separately (not as cool):
</p>
<pre>include_css 'reset', 'application', 'clearfix'
=> <link href="/stylesheets/reset.min.css" ... />
 <link href="/stylesheets/application.min.css" ... />
 <link href="/stylesheets/clearfix.min.css" ... /></pre>
+ <p>
+ Include a stylesheet with extra media types:
+ </p>
+ <pre>include_css 'mobile', :media => 'handheld,screen,projection'
=> <link href="/stylesheets/mobile.min.css"
 media="handheld,screen,projection" ... /></pre>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000023-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000027-source'); return false">
[show source]
</a>
- <pre id='M000023-source'> <span class="ruby-comment cmt"># File app/helpers/asset_hat_helper.rb, line 122</span>
122: <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>)
123: <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>
124: 
125: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span> <span class="ruby-operator">||=</span> {}
126: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>] <span class="ruby-operator">||=</span> {}
127: <span class="ruby-identifier">cache_key</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">inspect</span>
128: 
129: <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>
130: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
131: <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>] = <span class="ruby-identifier">include_assets</span>(<span class="ruby-identifier">:css</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
132: <span class="ruby-keyword kw">end</span>
133: 
134: <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>]
135: <span class="ruby-identifier">html</span>
136: <span class="ruby-keyword kw">end</span></pre>
+ <pre id='M000027-source'> <span class="ruby-comment cmt"># File app/helpers/asset_hat_helper.rb, line 129</span>
129: <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>)
130: <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>
131: 
132: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span> <span class="ruby-operator">||=</span> {}
133: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:css</span>] <span class="ruby-operator">||=</span> {}
134: 
135: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
136: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys!</span>.<span class="ruby-identifier">reverse_merge!</span>(
137: <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>)
138: <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>
139: 
140: <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>
141: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
142: <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>
143: <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>] =
144: <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>]))
145: <span class="ruby-keyword kw">end</span>
146: 
147: <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>]
148: <span class="ruby-identifier">html</span>
149: <span class="ruby-keyword kw">end</span></pre>
</div>
</div>
- <div class='method public-instance' id='method-M000024'>
- <a name='M000024'></a>
+ <div class='method public-instance' id='method-M000028'>
+ <a name='M000028'></a>
<div class='synopsis'>
<span class='name'>include_js</span>
<span class='arguments'>(*args)</span>
</div>
<div class='description'>
<p>
- <tt><a href="AssetHatHelper.html#M000024">include_js</a></tt> is a smart
+ <tt><a href="AssetHatHelper.html#M000028">include_js</a></tt> is a smart
wrapper for Rails’ <tt>javascript_include_tag</tt>. The two can be
used together while migrating to <a href="AssetHat.html">AssetHat</a>.
</p>
<p>
Include a single JS file:
@@ -124,14 +128,14 @@
</p>
<pre>include_js 'application.js'
=> <script src="/javascripts/application.js" type="text/javascript"></script></pre>
<p>
Include jQuery:
</p>
- <pre>include_js :jquery # Development/test environment
=> <script src="/javascripts/jquery-VERSION.min.js" ...></script>
include_js :jquery # Staging/production environment
=> <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.4'`.</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.4'`.</pre>
<p>
Include a bundle of JS files (i.e., a concatenated set of files; configure
- in config/assets.yml):
+ in <tt>config/assets.yml</tt>):
</p>
<pre>include_js :bundle => 'application'
=> <script src="/javascripts/bundles/application.min.js" ...></script></pre>
<p>
Include multiple bundles of JS files:
</p>
@@ -140,13 +144,13 @@
Include multiple JS files separately (not as cool):
</p>
<pre>include_js 'bloombox', 'jquery.cookie', 'jquery.json.min'
=> <script src="/javascripts/bloombox.min.js" ...></script>
 <script src="/javascripts/jquery.cookie.min.js" ...></script>
 <script src="/javascripts/jquery.json.min.js" ...></script></pre>
</div>
<div class='source'>
- <a class='source-toggle' href='#' onclick="toggleCode('M000024-source'); return false">
+ <a class='source-toggle' href='#' onclick="toggleCode('M000028-source'); return false">
[show source]
</a>
- <pre id='M000024-source'> <span class="ruby-comment cmt"># File app/helpers/asset_hat_helper.rb, line 173</span>
173: <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>)
174: <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>
175: 
176: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span> <span class="ruby-operator">||=</span> {}
177: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>] <span class="ruby-operator">||=</span> {}
178: <span class="ruby-identifier">cache_key</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">inspect</span>
179: 
180: <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>
181: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
182: 
183: <span class="ruby-identifier">html</span> = []
184: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
185: 
186: <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>)
187: <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>
188: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">vendor</span>
189: <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>(<span class="ruby-identifier">vendor</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-identifier">:version</span>))
190: <span class="ruby-identifier">html</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>, <span class="ruby-identifier">:cache</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>)
191: <span class="ruby-keyword kw">end</span>
192: 
193: <span class="ruby-identifier">html</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">options</span>]))
194: <span class="ruby-identifier">html</span> = <span class="ruby-identifier">html</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>).<span class="ruby-identifier">strip</span>
195: <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>
196: <span class="ruby-keyword kw">end</span>
197: 
198: <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>]
199: <span class="ruby-identifier">html</span>
200: <span class="ruby-keyword kw">end</span></pre>
+ <pre id='M000028-source'> <span class="ruby-comment cmt"># File app/helpers/asset_hat_helper.rb, line 189</span>
189: <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>)
190: <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>
191: 
192: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span> <span class="ruby-operator">||=</span> {}
193: <span class="ruby-constant">AssetHat</span>.<span class="ruby-identifier">html_cache</span>[<span class="ruby-identifier">:js</span>] <span class="ruby-operator">||=</span> {}
194: 
195: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
196: <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>)
197: <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>
198: 
199: <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>
200: <span class="ruby-comment cmt"># Generate HTML and write to cache</span>
201: 
202: <span class="ruby-identifier">html</span> = []
203: <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>)
204: <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>
205: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">vendor</span>
206: <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>(
207: <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>))
208: <span class="ruby-identifier">html</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>, <span class="ruby-identifier">:cache</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>)
209: <span class="ruby-keyword kw">end</span>
210: 
211: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">except!</span> <span class="ruby-identifier">:ssl</span>, <span class="ruby-identifier">:version</span>
212: 
213: <span class="ruby-identifier">html</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">options</span>]))
214: <span class="ruby-identifier">html</span> = <span class="ruby-identifier">html</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>).<span class="ruby-identifier">strip</span>
215: <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>
216: <span class="ruby-keyword kw">end</span>
217: 
218: <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>]
219: <span class="ruby-identifier">html</span>
220: <span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
</div>
</div>