ymdp 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -1
- data/VERSION +1 -1
- data/doc/ActionView.html +175 -0
- data/doc/ActionView/Helpers.html +175 -0
- data/doc/ActionView/Helpers/TagHelper.html +439 -0
- data/doc/Application.html +295 -0
- data/doc/LICENSE.html +158 -0
- data/doc/Object.html +218 -0
- data/doc/README_rdoc.html +147 -0
- data/doc/YMDP.html +232 -0
- data/doc/YMDP/ApplicationView.html +563 -0
- data/doc/YMDP/AssetTagHelper.html +235 -0
- data/doc/YMDP/Base.html +560 -0
- data/doc/YMDP/Compiler.html +178 -0
- data/doc/YMDP/Compiler/Base.html +1181 -0
- data/doc/YMDP/Compiler/Domains.html +493 -0
- data/doc/YMDP/Compiler/Options.html +265 -0
- data/doc/YMDP/Compiler/Template.html +175 -0
- data/doc/YMDP/Compiler/Template/Base.html +911 -0
- data/doc/YMDP/Compiler/Template/CoffeeScript.html +236 -0
- data/doc/YMDP/Compiler/Template/JavaScript.html +237 -0
- data/doc/YMDP/Compiler/Template/View.html +495 -0
- data/doc/YMDP/Compiler/Template/YRB.html +469 -0
- data/doc/YMDP/Configuration.html +175 -0
- data/doc/YMDP/Configuration/Base.html +426 -0
- data/doc/YMDP/Configuration/Config.html +553 -0
- data/doc/YMDP/Configuration/Servers.html +265 -0
- data/doc/YMDP/Configuration/Setter.html +580 -0
- data/doc/YMDP/FormTagHelper.html +298 -0
- data/doc/YMDP/GitHelper.html +298 -0
- data/doc/YMDP/LinkTagHelper.html +299 -0
- data/doc/YMDP/View.html +239 -0
- data/doc/created.rid +18 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +134 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +543 -0
- data/doc/table_of_contents.html +401 -0
- data/lib/ymdp/compiler/template.rb +5 -1
- data/lib/ymdp/view/application_view.rb +10 -5
- data/ymdp.gemspec +69 -2
- metadata +120 -42
@@ -0,0 +1,563 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>module YMDP::ApplicationView - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="module">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../index.html">Home</a>
|
28
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
<div id="file-metadata">
|
47
|
+
<nav id="file-list-section" class="section">
|
48
|
+
<h3 class="section-header">Defined In</h3>
|
49
|
+
<ul>
|
50
|
+
<li>lib/ymdp/view/application_view.rb
|
51
|
+
</ul>
|
52
|
+
</nav>
|
53
|
+
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div id="class-metadata">
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<!-- Method Quickref -->
|
62
|
+
<nav id="method-list-section" class="section">
|
63
|
+
<h3 class="section-header">Methods</h3>
|
64
|
+
|
65
|
+
<ul class="link-list">
|
66
|
+
|
67
|
+
<li><a href="#method-i-combo">#combo</a>
|
68
|
+
|
69
|
+
<li><a href="#method-i-english_languages">#english_languages</a>
|
70
|
+
|
71
|
+
<li><a href="#method-i-include_firebug_lite">#include_firebug_lite</a>
|
72
|
+
|
73
|
+
<li><a href="#method-i-javascript_include">#javascript_include</a>
|
74
|
+
|
75
|
+
<li><a href="#method-i-render">#render</a>
|
76
|
+
|
77
|
+
<li><a href="#method-i-supported_languages">#supported_languages</a>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<div id="project-metadata">
|
85
|
+
<nav id="fileindex-section" class="section project-section">
|
86
|
+
<h3 class="section-header">Pages</h3>
|
87
|
+
|
88
|
+
<ul>
|
89
|
+
|
90
|
+
<li class="file"><a href="../LICENSE.html">LICENSE</a>
|
91
|
+
|
92
|
+
<li class="file"><a href="../README_rdoc.html">README</a>
|
93
|
+
|
94
|
+
</ul>
|
95
|
+
</nav>
|
96
|
+
|
97
|
+
<nav id="classindex-section" class="section project-section">
|
98
|
+
<h3 class="section-header">Class and Module Index</h3>
|
99
|
+
|
100
|
+
<ul class="link-list">
|
101
|
+
|
102
|
+
<li><a href="../YMDP.html">YMDP</a>
|
103
|
+
|
104
|
+
<li><a href="../YMDP/ApplicationView.html">YMDP::ApplicationView</a>
|
105
|
+
|
106
|
+
<li><a href="../YMDP/AssetTagHelper.html">YMDP::AssetTagHelper</a>
|
107
|
+
|
108
|
+
<li><a href="../YMDP/Base.html">YMDP::Base</a>
|
109
|
+
|
110
|
+
<li><a href="../YMDP/Compiler.html">YMDP::Compiler</a>
|
111
|
+
|
112
|
+
<li><a href="../YMDP/Compiler/Base.html">YMDP::Compiler::Base</a>
|
113
|
+
|
114
|
+
<li><a href="../YMDP/Compiler/Domains.html">YMDP::Compiler::Domains</a>
|
115
|
+
|
116
|
+
<li><a href="../YMDP/Compiler/Options.html">YMDP::Compiler::Options</a>
|
117
|
+
|
118
|
+
<li><a href="../YMDP/Compiler/Template.html">YMDP::Compiler::Template</a>
|
119
|
+
|
120
|
+
<li><a href="../YMDP/Compiler/Template/Base.html">YMDP::Compiler::Template::Base</a>
|
121
|
+
|
122
|
+
<li><a href="../YMDP/Compiler/Template/CoffeeScript.html">YMDP::Compiler::Template::CoffeeScript</a>
|
123
|
+
|
124
|
+
<li><a href="../YMDP/Compiler/Template/JavaScript.html">YMDP::Compiler::Template::JavaScript</a>
|
125
|
+
|
126
|
+
<li><a href="../YMDP/Compiler/Template/View.html">YMDP::Compiler::Template::View</a>
|
127
|
+
|
128
|
+
<li><a href="../YMDP/Compiler/Template/YRB.html">YMDP::Compiler::Template::YRB</a>
|
129
|
+
|
130
|
+
<li><a href="../YMDP/Configuration.html">YMDP::Configuration</a>
|
131
|
+
|
132
|
+
<li><a href="../YMDP/Configuration/Base.html">YMDP::Configuration::Base</a>
|
133
|
+
|
134
|
+
<li><a href="../YMDP/Configuration/Config.html">YMDP::Configuration::Config</a>
|
135
|
+
|
136
|
+
<li><a href="../YMDP/Configuration/Servers.html">YMDP::Configuration::Servers</a>
|
137
|
+
|
138
|
+
<li><a href="../YMDP/Configuration/Setter.html">YMDP::Configuration::Setter</a>
|
139
|
+
|
140
|
+
<li><a href="../YMDP/FormTagHelper.html">YMDP::FormTagHelper</a>
|
141
|
+
|
142
|
+
<li><a href="../YMDP/GitHelper.html">YMDP::GitHelper</a>
|
143
|
+
|
144
|
+
<li><a href="../YMDP/LinkTagHelper.html">YMDP::LinkTagHelper</a>
|
145
|
+
|
146
|
+
<li><a href="../YMDP/View.html">YMDP::View</a>
|
147
|
+
|
148
|
+
<li><a href="../ActionView.html">ActionView</a>
|
149
|
+
|
150
|
+
<li><a href="../ActionView/Helpers.html">ActionView::Helpers</a>
|
151
|
+
|
152
|
+
<li><a href="../ActionView/Helpers/TagHelper.html">ActionView::Helpers::TagHelper</a>
|
153
|
+
|
154
|
+
<li><a href="../Application.html">Application</a>
|
155
|
+
|
156
|
+
<li><a href="../Object.html">Object</a>
|
157
|
+
|
158
|
+
</ul>
|
159
|
+
</nav>
|
160
|
+
|
161
|
+
</div>
|
162
|
+
</nav>
|
163
|
+
|
164
|
+
<div id="documentation">
|
165
|
+
<h1 class="module">module YMDP::ApplicationView</h1>
|
166
|
+
|
167
|
+
<div id="description" class="description">
|
168
|
+
|
169
|
+
<p>Contains all the functions which are available from inside a view file,
|
170
|
+
whether that view is HTML, JavaScript or CSS.</p>
|
171
|
+
|
172
|
+
</div><!-- description -->
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
<!-- Methods -->
|
187
|
+
|
188
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
189
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
190
|
+
|
191
|
+
|
192
|
+
<div id="method-i-combo" class="method-detail ">
|
193
|
+
|
194
|
+
<div class="method-heading">
|
195
|
+
<span class="method-name">combo</span><span
|
196
|
+
class="method-args">(filenames, options={})</span>
|
197
|
+
<span class="method-click-advice">click to toggle source</span>
|
198
|
+
</div>
|
199
|
+
|
200
|
+
|
201
|
+
<div class="method-description">
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<div class="method-source-code" id="combo-source">
|
208
|
+
<pre><span class="ruby-comment"># File lib/ymdp/view/application_view.rb, line 81</span>
|
209
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">combo</span>(<span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>={})
|
210
|
+
<span class="ruby-identifier">paths</span> = <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
211
|
+
<span class="ruby-node">"javascripts/#{filename}"</span>
|
212
|
+
<span class="ruby-keyword">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">"&"</span>)
|
213
|
+
<span class="ruby-node">"<script src=\"/yahoo/mail/combo?#{paths}\"></script>"</span>
|
214
|
+
<span class="ruby-keyword">end</span></pre>
|
215
|
+
</div><!-- combo-source -->
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
</div><!-- combo-method -->
|
223
|
+
|
224
|
+
|
225
|
+
<div id="method-i-english_languages" class="method-detail ">
|
226
|
+
|
227
|
+
<div class="method-heading">
|
228
|
+
<span class="method-name">english_languages</span><span
|
229
|
+
class="method-args">()</span>
|
230
|
+
<span class="method-click-advice">click to toggle source</span>
|
231
|
+
</div>
|
232
|
+
|
233
|
+
|
234
|
+
<div class="method-description">
|
235
|
+
|
236
|
+
<p>Returns an array of country codes of English-speaking countries supported
|
237
|
+
by the application, based on the language-specific folders located in
|
238
|
+
“app/assets/yrb”.</p>
|
239
|
+
|
240
|
+
<h4 id="method-i-english_languages-label-Examples">Examples</h4>
|
241
|
+
|
242
|
+
<pre class="ruby"><span class="ruby-identifier">english_languages</span>
|
243
|
+
<span class="ruby-comment"># => ["en-US", "en-AU", "en-SG", "en-MY"]</span>
|
244
|
+
</pre>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
<div class="method-source-code" id="english_languages-source">
|
249
|
+
<pre><span class="ruby-comment"># File lib/ymdp/view/application_view.rb, line 42</span>
|
250
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">english_languages</span>
|
251
|
+
<span class="ruby-identifier">supported_languages</span>.<span class="ruby-identifier">select</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lang</span><span class="ruby-operator">|</span>
|
252
|
+
<span class="ruby-identifier">lang</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r^en/</span>
|
253
|
+
<span class="ruby-keyword">end</span>
|
254
|
+
<span class="ruby-keyword">end</span></pre>
|
255
|
+
</div><!-- english_languages-source -->
|
256
|
+
|
257
|
+
</div>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
</div><!-- english_languages-method -->
|
263
|
+
|
264
|
+
|
265
|
+
<div id="method-i-include_firebug_lite" class="method-detail ">
|
266
|
+
|
267
|
+
<div class="method-heading">
|
268
|
+
<span class="method-name">include_firebug_lite</span><span
|
269
|
+
class="method-args">()</span>
|
270
|
+
<span class="method-click-advice">click to toggle source</span>
|
271
|
+
</div>
|
272
|
+
|
273
|
+
|
274
|
+
<div class="method-description">
|
275
|
+
|
276
|
+
<p>Renders a link to include Firebug Lite for debugging JavaScript in Internet
|
277
|
+
Explorer.</p>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<div class="method-source-code" id="include_firebug_lite-source">
|
282
|
+
<pre><span class="ruby-comment"># File lib/ymdp/view/application_view.rb, line 90</span>
|
283
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">include_firebug_lite</span>
|
284
|
+
<span class="ruby-identifier">javascript_include</span> <span class="ruby-string">"http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"</span>
|
285
|
+
<span class="ruby-keyword">end</span></pre>
|
286
|
+
</div><!-- include_firebug_lite-source -->
|
287
|
+
|
288
|
+
</div>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
</div><!-- include_firebug_lite-method -->
|
294
|
+
|
295
|
+
|
296
|
+
<div id="method-i-javascript_include" class="method-detail ">
|
297
|
+
|
298
|
+
<div class="method-heading">
|
299
|
+
<span class="method-name">javascript_include</span><span
|
300
|
+
class="method-args">(filename, options={})</span>
|
301
|
+
<span class="method-click-advice">click to toggle source</span>
|
302
|
+
</div>
|
303
|
+
|
304
|
+
|
305
|
+
<div class="method-description">
|
306
|
+
|
307
|
+
<p>Includes a JavaScript file in a view. If the filename is a full path, the
|
308
|
+
JavaScript file will be linked as an external asset. If not, the file will
|
309
|
+
linked as a local asset located in the <a href="../YMDP.html">YMDP</a>
|
310
|
+
application’s assets directory.</p>
|
311
|
+
|
312
|
+
<h3 id="method-i-javascript_include-label-Local+JavaScript+Assets">Local JavaScript Assets</h3>
|
313
|
+
|
314
|
+
<pre>javascript_include("application.js")</pre>
|
315
|
+
|
316
|
+
<p>will produce:</p>
|
317
|
+
|
318
|
+
<pre><script src='/om/assets/3ifh3b2kjf_1/assets/javascripts/application.js'
|
319
|
+
type='text/javascript charset='utf-8'></script></pre>
|
320
|
+
|
321
|
+
<h3 id="method-i-javascript_include-label-External+JavaScript+Assets">External JavaScript Assets</h3>
|
322
|
+
|
323
|
+
<pre>javascript_include("http://www.myserver.com/javascripts/application.js")</pre>
|
324
|
+
|
325
|
+
<p>will produce:</p>
|
326
|
+
|
327
|
+
<pre><script src='http://www.myserver.com/javascripts/application.js' type='text/javascript
|
328
|
+
charset='utf-8'></script></pre>
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
<div class="method-source-code" id="javascript_include-source">
|
333
|
+
<pre><span class="ruby-comment"># File lib/ymdp/view/application_view.rb, line 70</span>
|
334
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">javascript_include</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">options</span>={})
|
335
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">filename</span> <span class="ruby-operator">==</span> <span class="ruby-value">:defaults</span>
|
336
|
+
<span class="ruby-identifier">render_default_javascripts</span>(<span class="ruby-identifier">options</span>)
|
337
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-string">"defaults.js"</span>
|
338
|
+
<span class="ruby-keyword">end</span>
|
339
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">filename</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r^http/</span>
|
340
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-node">"#{@assets_directory}/javascripts/#{filename}"</span>
|
341
|
+
<span class="ruby-keyword">end</span>
|
342
|
+
<span class="ruby-node">"<script src='#{filename}' type='text/javascript' charset='utf-8'></script>"</span>
|
343
|
+
<span class="ruby-keyword">end</span></pre>
|
344
|
+
</div><!-- javascript_include-source -->
|
345
|
+
|
346
|
+
</div>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
</div><!-- javascript_include-method -->
|
352
|
+
|
353
|
+
|
354
|
+
<div id="method-i-render" class="method-detail ">
|
355
|
+
|
356
|
+
<div class="method-heading">
|
357
|
+
<span class="method-name">render</span><span
|
358
|
+
class="method-args">(params)</span>
|
359
|
+
<span class="method-click-advice">click to toggle source</span>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
|
363
|
+
<div class="method-description">
|
364
|
+
|
365
|
+
<p>Renders a partial into the current view. HTML partial names must be
|
366
|
+
preceded with an underscore.</p>
|
367
|
+
|
368
|
+
<h2 id="method-i-render-label-Rendering+an+HTML+partial">Rendering an HTML partial</h2>
|
369
|
+
|
370
|
+
<p>HTML partials are located in <code>app/views</code>. HTML view files can be
|
371
|
+
Haml or ERB. Haml is recommended and takes preference. HTML partials are
|
372
|
+
named <code>_<em>filename</em>.html.haml</code> or
|
373
|
+
<code>_<em>filename</em>.html.erb</code>.</p>
|
374
|
+
|
375
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">partial</span> =<span class="ruby-operator">></span> <span class="ruby-string">'sidebar'</span>
|
376
|
+
</pre>
|
377
|
+
|
378
|
+
<p>will find <code>app/views/_sidebar.html.haml</code> or
|
379
|
+
<code>app/views/_sidebar.html.erb</code> and render its contents into the
|
380
|
+
current view.</p>
|
381
|
+
|
382
|
+
<p>Specify a full path to indicate a specific template.</p>
|
383
|
+
|
384
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">partial</span> =<span class="ruby-operator">></span> <span class="ruby-string">'sidebar.html.erb'</span>
|
385
|
+
</pre>
|
386
|
+
|
387
|
+
<p>will find <code>app/views/_sidebar.html.erb'</code> and render it even if
|
388
|
+
<code>app/views/_sidebar.html.haml</code> exists.</p>
|
389
|
+
|
390
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">partial</span> =<span class="ruby-operator">></span> <span class="ruby-string">'shared/sidebar'</span>
|
391
|
+
</pre>
|
392
|
+
|
393
|
+
<p>will find <code>app/views/shared/_sidebar.html.haml</code> and render its
|
394
|
+
contents into the current view.</p>
|
395
|
+
|
396
|
+
<h2 id="method-i-render-label-Rendering+a+JavaScript+partial">Rendering a JavaScript partial</h2>
|
397
|
+
|
398
|
+
<p>You can render a single JavaScript file or send an array to concatenate a
|
399
|
+
set of JavaScript files together asone script block.</p>
|
400
|
+
|
401
|
+
<h3 id="method-i-render-label-Rendering+a+single+JavaScript+partial">Rendering a single JavaScript partial</h3>
|
402
|
+
|
403
|
+
<p>JavaScript partials are located in <code>app/javascripts</code> and are
|
404
|
+
named <code><em>filename</em>.js</code></p>
|
405
|
+
|
406
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">javascript</span> =<span class="ruby-operator">></span> <span class="ruby-string">'application'</span>
|
407
|
+
</pre>
|
408
|
+
|
409
|
+
<p>will find <code>app/javascripts/application.js</code> and render its
|
410
|
+
contents into the current view in an inline script block.</p>
|
411
|
+
|
412
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">javascript</span> =<span class="ruby-operator">></span> <span class="ruby-string">'shared/sidebar'</span>
|
413
|
+
</pre>
|
414
|
+
|
415
|
+
<p>will find <code>app/javascripts/shared/sidebar.js</code> and render its
|
416
|
+
contents into the current view in an inline script block.</p>
|
417
|
+
|
418
|
+
<h2 id="method-i-render-label-Rendering+a+stylesheet+partial">Rendering a stylesheet partial</h2>
|
419
|
+
|
420
|
+
<p>Stylesheets are located at <code>app/stylesheets</code> and are named
|
421
|
+
<code><em>filename</em>.css</code></p>
|
422
|
+
|
423
|
+
<h3 id="method-i-render-label-Rendering+multiple+partials">Rendering multiple partials</h3>
|
424
|
+
|
425
|
+
<p>Pass an array to <code>render</code> to combine multiple files into a
|
426
|
+
single inline block. This is useful for compression and validation, as it
|
427
|
+
allows a set of files to be compressed or validated in a single context.</p>
|
428
|
+
|
429
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">javascript</span> =<span class="ruby-operator">></span> [<span class="ruby-string">'application'</span>, <span class="ruby-string">'flash'</span>, <span class="ruby-string">'debug'</span>]
|
430
|
+
</pre>
|
431
|
+
|
432
|
+
<p>will combine the contents of <code>app/javascripts/application.js</code>,
|
433
|
+
<code>app/javascripts/application.js</code>, and
|
434
|
+
<code>app/javascripts/application.js</code> into a single script block in
|
435
|
+
the current view.</p>
|
436
|
+
|
437
|
+
<p>Pass a <code>:filename</code> parameter to set the name of the combined
|
438
|
+
file. Currently the combined file only exists on disc while it’s being
|
439
|
+
compressed and/or validated, but in the future this may be expanded to save
|
440
|
+
multiple files as a single external asset.</p>
|
441
|
+
|
442
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">javascript</span> =<span class="ruby-operator">></span> [<span class="ruby-string">'application'</span>, <span class="ruby-string">'flash'</span>, <span class="ruby-string">'debug'</span>], :<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'javascripts'</span>
|
443
|
+
</pre>
|
444
|
+
|
445
|
+
<p>Currently the <code>:filename</code> parameter is simply a convenience.</p>
|
446
|
+
|
447
|
+
<p>Multiple partials of any type can be rendered.</p>
|
448
|
+
|
449
|
+
<p>For example:</p>
|
450
|
+
|
451
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">partial</span> =<span class="ruby-operator">></span> [<span class="ruby-string">'header'</span>, <span class="ruby-string">'footer'</span>, <span class="ruby-string">'sidebar'</span>], :<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'html_layouts'</span>
|
452
|
+
</pre>
|
453
|
+
|
454
|
+
<p>will find <code>app/views/_header.html.haml</code>,
|
455
|
+
<code>app/views/_footer.html.haml</code>, and
|
456
|
+
<code>app/views/_sidebar.html.haml</code> and write them to a temporary
|
457
|
+
file called <code>tmp/html_layouts</code> before rendering that file into
|
458
|
+
the current view.</p>
|
459
|
+
|
460
|
+
<p>This feature is intended mainly for JavaScript and CSS.</p>
|
461
|
+
|
462
|
+
<p>For example:</p>
|
463
|
+
|
464
|
+
<pre class="ruby"><span class="ruby-identifier">render</span> :<span class="ruby-identifier">stylesheet</span> =<span class="ruby-operator">></span> [<span class="ruby-string">'application'</span>, <span class="ruby-string">'colors'</span>], :<span class="ruby-identifier">filename</span> =<span class="ruby-operator">></span> <span class="ruby-string">'styles'</span>
|
465
|
+
</pre>
|
466
|
+
|
467
|
+
<p>will render <code>app/stylesheets/application.css</code> and
|
468
|
+
<code>app/stylesheets/colors.css</code> as a single temporary file called
|
469
|
+
<code>tmp/styles</code> before rendering that file into the current view.</p>
|
470
|
+
|
471
|
+
<p>If compression and validation options are turned on, the resulting
|
472
|
+
temporary file will be compressed and/or validated before being rendered
|
473
|
+
into the current view. This will result in a more efficient compression
|
474
|
+
and a more effective validation.</p>
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
<div class="method-source-code" id="render-source">
|
479
|
+
<pre><span class="ruby-comment"># File lib/ymdp/view/application_view.rb, line 186</span>
|
480
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">params</span>)
|
481
|
+
<span class="ruby-identifier">output</span> = []
|
482
|
+
|
483
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:tags</span>)
|
484
|
+
<span class="ruby-identifier">params</span>[<span class="ruby-value">:tags</span>] = <span class="ruby-keyword">true</span>
|
485
|
+
<span class="ruby-keyword">end</span>
|
486
|
+
|
487
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">render_html_partial</span>(<span class="ruby-identifier">params</span>)
|
488
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">render_javascript_partial</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:javascript</span>]
|
489
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">render_stylesheet_partial</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:stylesheet</span>]
|
490
|
+
|
491
|
+
<span class="ruby-identifier">output</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>)
|
492
|
+
<span class="ruby-keyword">end</span></pre>
|
493
|
+
</div><!-- render-source -->
|
494
|
+
|
495
|
+
</div>
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
</div><!-- render-method -->
|
501
|
+
|
502
|
+
|
503
|
+
<div id="method-i-supported_languages" class="method-detail ">
|
504
|
+
|
505
|
+
<div class="method-heading">
|
506
|
+
<span class="method-name">supported_languages</span><span
|
507
|
+
class="method-args">()</span>
|
508
|
+
<span class="method-click-advice">click to toggle source</span>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
|
512
|
+
<div class="method-description">
|
513
|
+
|
514
|
+
<p>Returns an array of the country codes of all languages supported by the
|
515
|
+
application, which is determined by the language-specific folders in
|
516
|
+
“app/assets/yrb”.</p>
|
517
|
+
|
518
|
+
<h4 id="method-i-supported_languages-label-Examples">Examples</h4>
|
519
|
+
|
520
|
+
<pre class="ruby"><span class="ruby-identifier">supported_languages</span>
|
521
|
+
<span class="ruby-comment"># => ["en-US", "de-DE", "es-ES", "es-MX"]</span>
|
522
|
+
</pre>
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
<div class="method-source-code" id="supported_languages-source">
|
527
|
+
<pre><span class="ruby-comment"># File lib/ymdp/view/application_view.rb, line 20</span>
|
528
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">supported_languages</span>
|
529
|
+
<span class="ruby-identifier">dirs</span> = <span class="ruby-constant">Dir</span>[<span class="ruby-node">"#{BASE_PATH}/app/assets/yrb/*"</span>].<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
|
530
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">"/"</span>).<span class="ruby-identifier">last</span>
|
531
|
+
|
532
|
+
<span class="ruby-identifier">filename</span>
|
533
|
+
<span class="ruby-keyword">end</span>
|
534
|
+
|
535
|
+
<span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">"en-US"</span>))
|
536
|
+
|
537
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-string">"Default YRB key en-US not found"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">"en-US"</span>)
|
538
|
+
|
539
|
+
<span class="ruby-identifier">dirs</span>
|
540
|
+
<span class="ruby-keyword">end</span></pre>
|
541
|
+
</div><!-- supported_languages-source -->
|
542
|
+
|
543
|
+
</div>
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
</div><!-- supported_languages-method -->
|
549
|
+
|
550
|
+
|
551
|
+
</section><!-- public-instance-method-details -->
|
552
|
+
|
553
|
+
</section><!-- 5Buntitled-5D -->
|
554
|
+
|
555
|
+
</div><!-- documentation -->
|
556
|
+
|
557
|
+
|
558
|
+
<footer id="validator-badges">
|
559
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
560
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
561
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
562
|
+
</footer>
|
563
|
+
|