ember 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ (the ISC license)
2
+
3
+ Copyright 2009 Suraj N. Kurapati <sunaku@gmail.com>
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # Evaluates eRuby directives in the given eRuby template and
4
+ # writes the result to the standard output stream (STDOUT).
5
+ #
6
+ #
7
+ # Usage:
8
+ #
9
+ # ember [Options] [Source]
10
+ #
11
+ #
12
+ # Source: Path to an eRuby template file. If this parameter is
13
+ # not specified, then the result of reading the standard
14
+ # input stream (STDIN) will be used as the eRuby template.
15
+ #
16
+ #
17
+ # Options:
18
+ #
19
+
20
+ #--
21
+ # Copyright 2009 Suraj N. Kurapati
22
+ # See the LICENSE file for details.
23
+ #++
24
+
25
+ require 'rubygems'
26
+ gem 'inochi', '~> 1'
27
+ require 'inochi'
28
+
29
+ options = Inochi.main :Ember do
30
+ opt :shorthand, 'Treat lines beginning with "%" as directives'
31
+ opt :infer_end, 'Add "end" statements based on indentation'
32
+ opt :unindent, 'Unindent block content hierarchically'
33
+ opt :compile, 'Print template program and exit'
34
+ end
35
+
36
+ template =
37
+ if source = ARGV.shift
38
+ Ember::Template.load_file(source, options)
39
+ else
40
+ Ember::Template.new(STDIN.read, options)
41
+ end
42
+
43
+ if options[:compile]
44
+ puts template.program
45
+ else
46
+ puts template.render
47
+ end
@@ -0,0 +1,61 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <title>Ember</title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
+ <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
9
+ <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
10
+ <script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
11
+ <script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
12
+ <script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
13
+ </head>
14
+
15
+ <body>
16
+ <div class="banner">
17
+ <h1>
18
+ <span class="type">Module</span>
19
+ Ember
20
+
21
+ </h1>
22
+ <ul class="files">
23
+
24
+ <li><a href="../files/lib/ember/template_rb.html">lib/ember/template.rb</a></li>
25
+
26
+ </ul>
27
+ </div>
28
+ <div id="bodyContent">
29
+ <div id="content">
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+ <div class="sectiontitle">Classes and Modules</div>
46
+ <ul>
47
+
48
+ <li><span class="type">CLASS</span> <a href="Ember/Template.html">Ember::Template</a></li>
49
+
50
+ </ul>
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ </div>
59
+ </div>
60
+ </body>
61
+ </html>
@@ -0,0 +1,396 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <title>Ember::Template</title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
+ <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
9
+ <link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
10
+ <script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
11
+ <script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
12
+ <script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
13
+ </head>
14
+
15
+ <body>
16
+ <div class="banner">
17
+ <h1>
18
+ <span class="type">Class</span>
19
+ Ember::Template
20
+
21
+ <span class="parent">&lt;
22
+
23
+ Object
24
+
25
+ </span>
26
+
27
+ </h1>
28
+ <ul class="files">
29
+
30
+ <li><a href="../../files/lib/ember/template_rb.html">lib/ember/template.rb</a></li>
31
+
32
+ </ul>
33
+ </div>
34
+ <div id="bodyContent">
35
+ <div id="content">
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+ <div class="sectiontitle">Methods</div>
46
+ <dl class="methods">
47
+
48
+ <dt>L</dt>
49
+ <dd>
50
+ <ul>
51
+
52
+ <li><a href="#M000003">load_file</a></li>
53
+
54
+ </ul>
55
+ </dd>
56
+
57
+ <dt>N</dt>
58
+ <dd>
59
+ <ul>
60
+
61
+ <li><a href="#M000000">new</a></li>
62
+
63
+ </ul>
64
+ </dd>
65
+
66
+ <dt>P</dt>
67
+ <dd>
68
+ <ul>
69
+
70
+ <li><a href="#M000001">program</a></li>
71
+
72
+ </ul>
73
+ </dd>
74
+
75
+ <dt>R</dt>
76
+ <dd>
77
+ <ul>
78
+
79
+ <li><a href="#M000004">read_file</a>,</li>
80
+
81
+ <li><a href="#M000002">render</a></li>
82
+
83
+ </ul>
84
+ </dd>
85
+
86
+ </dl>
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+ <div class="sectiontitle">Classes and Modules</div>
95
+ <ul>
96
+
97
+ <li><span class="type">CLASS</span> <a href="Template/Program.html">Ember::Template::Program</a></li>
98
+
99
+ </ul>
100
+
101
+
102
+
103
+ <div class="sectiontitle">Constants</div>
104
+ <table border='0' cellpadding='5'>
105
+
106
+ <tr valign='top'>
107
+ <td class="attr-name">OPERATION_EVAL_EXPRESSION</td>
108
+ <td>=</td>
109
+ <td class="attr-value">'='</td>
110
+ </tr>
111
+
112
+
113
+ <tr valign='top'>
114
+ <td class="attr-name">OPERATION_COMMENT_LINE</td>
115
+ <td>=</td>
116
+ <td class="attr-value">'#'</td>
117
+ </tr>
118
+
119
+
120
+ <tr valign='top'>
121
+ <td class="attr-name">OPERATION_BEGIN_LAMBDA</td>
122
+ <td>=</td>
123
+ <td class="attr-value">'|'</td>
124
+ </tr>
125
+
126
+
127
+ <tr valign='top'>
128
+ <td class="attr-name">OPERATION_EVAL_TEMPLATE_FILE</td>
129
+ <td>=</td>
130
+ <td class="attr-value">'+'</td>
131
+ </tr>
132
+
133
+
134
+ <tr valign='top'>
135
+ <td class="attr-name">OPERATION_EVAL_TEMPLATE_STRING</td>
136
+ <td>=</td>
137
+ <td class="attr-value">'~'</td>
138
+ </tr>
139
+
140
+
141
+ <tr valign='top'>
142
+ <td class="attr-name">OPERATION_INSERT_PLAIN_FILE</td>
143
+ <td>=</td>
144
+ <td class="attr-value">'&lt;'</td>
145
+ </tr>
146
+
147
+
148
+ </table>
149
+
150
+
151
+
152
+
153
+
154
+ <div class="sectiontitle">Class Public methods</div>
155
+
156
+ <div class="method">
157
+ <div class="title" id="M000003">
158
+
159
+ <a name="M000003"></a><b>load_file</b>(path, options = {})
160
+
161
+ </div>
162
+
163
+ <div class="description">
164
+ <p>
165
+ Builds a template whose body is read from the given source.
166
+ </p>
167
+ <p>
168
+ If the source is a relative path, it will be resolved relative to
169
+ options[:source_file] if that is a valid path.
170
+ </p>
171
+
172
+ </div>
173
+
174
+
175
+
176
+
177
+ <div class="sourcecode">
178
+ <p class="source-link">
179
+ Source: <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show</a>
180
+
181
+ </p>
182
+ <div id="M000003_source" class="dyn-source">
183
+ <pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 93</span>
184
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_file</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}
185
+ <span class="ruby-identifier">path</span> = <span class="ruby-identifier">resolve_path</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span>)
186
+ <span class="ruby-identifier">new</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:source_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">path</span>)
187
+ <span class="ruby-keyword kw">end</span></pre>
188
+ </div>
189
+ </div>
190
+
191
+ </div>
192
+
193
+ <div class="method">
194
+ <div class="title" id="M000000">
195
+
196
+ <a name="M000000"></a><b>new</b>(input, options = {})
197
+
198
+ </div>
199
+
200
+ <div class="description">
201
+ <p>
202
+ Builds a processor that evaluates eRuby directives in the given input
203
+ according to the given options.
204
+ </p>
205
+ <p>
206
+ This processor transforms the given input into an executable Ruby program
207
+ (provided by the to_s() method) which is then executed by the render()
208
+ method on demand.
209
+ </p>
210
+ <p>
211
+ eRuby directives that contribute to the output of the given template are
212
+ called &#8220;vocal&#8221; directives. Those that do not are called
213
+ &#8220;silent&#8221; directives.
214
+ </p>
215
+ <h4>Options</h4>
216
+ <dl>
217
+ <dt>:result_variable</dt><dd>Name of the variable which stores the result of template evaluation during
218
+ template evaluation.
219
+
220
+ <p>
221
+ The default value is &#8220;_erbout&#8221;.
222
+ </p>
223
+ </dd>
224
+ <dt>:continue_result</dt><dd>Append to the result variable if it already exists?
225
+
226
+ <p>
227
+ The default value is false.
228
+ </p>
229
+ </dd>
230
+ <dt>:source_file</dt><dd>Name of the file which contains the given input. This is shown in stack
231
+ traces when reporting error messages.
232
+
233
+ <p>
234
+ The default value is &#8220;SOURCE&#8221;.
235
+ </p>
236
+ </dd>
237
+ <dt>:source_line</dt><dd>Line number at which the given input exists in the :source_file. This is
238
+ shown in stack traces when reporting error messages.
239
+
240
+ <p>
241
+ The default value is 1.
242
+ </p>
243
+ </dd>
244
+ <dt>:shorthand</dt><dd>Treat lines beginning with &#8220;%&#8221; as eRuby directives?
245
+
246
+ <p>
247
+ The default value is false.
248
+ </p>
249
+ </dd>
250
+ <dt>:<a href="Template.html#M000009">infer_end</a></dt><dd>Add missing <% end %> statements based on indentation?
251
+
252
+ <p>
253
+ The default value is false.
254
+ </p>
255
+ </dd>
256
+ <dt>:unindent</dt><dd>Unindent the content of eRuby blocks (everything between <% do %> &#8230;
257
+ <% end %>) hierarchically?
258
+
259
+ <p>
260
+ The default value is false.
261
+ </p>
262
+ </dd>
263
+ </dl>
264
+
265
+ </div>
266
+
267
+
268
+
269
+
270
+ <div class="sourcecode">
271
+ <p class="source-link">
272
+ Source: <a href="javascript:toggleSource('M000000_source')" id="l_M000000_source">show</a>
273
+
274
+ </p>
275
+ <div id="M000000_source" class="dyn-source">
276
+ <pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 63</span>
277
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">input</span>, <span class="ruby-identifier">options</span> = {}
278
+ <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
279
+ <span class="ruby-ivar">@compile</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">input</span>.<span class="ruby-identifier">to_s</span>)
280
+ <span class="ruby-keyword kw">end</span></pre>
281
+ </div>
282
+ </div>
283
+
284
+ </div>
285
+
286
+ <div class="method">
287
+ <div class="title" id="M000004">
288
+
289
+ <a name="M000004"></a><b>read_file</b>(path, options = {})
290
+
291
+ </div>
292
+
293
+ <div class="description">
294
+ <p>
295
+ Returns the contents of the given file, which can be relative to the
296
+ current template in which this command is being executed.
297
+ </p>
298
+ <p>
299
+ If the source is a relative path, it will be resolved relative to
300
+ options[:source_file] if that is a valid path.
301
+ </p>
302
+
303
+ </div>
304
+
305
+
306
+
307
+
308
+ <div class="sourcecode">
309
+ <p class="source-link">
310
+ Source: <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show</a>
311
+
312
+ </p>
313
+ <div id="M000004_source" class="dyn-source">
314
+ <pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 105</span>
315
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_file</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}
316
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">resolve_path</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span>)
317
+ <span class="ruby-keyword kw">end</span></pre>
318
+ </div>
319
+ </div>
320
+
321
+ </div>
322
+
323
+ <div class="sectiontitle">Instance Public methods</div>
324
+
325
+ <div class="method">
326
+ <div class="title" id="M000001">
327
+
328
+ <a name="M000001"></a><b>program</b>()
329
+
330
+ </div>
331
+
332
+ <div class="description">
333
+ <p>
334
+ Ruby source code assembled from the eRuby template provided as input to the
335
+ constructor of this class.
336
+ </p>
337
+
338
+ </div>
339
+
340
+
341
+
342
+
343
+ <div class="sourcecode">
344
+ <p class="source-link">
345
+ Source: <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show</a>
346
+
347
+ </p>
348
+ <div id="M000001_source" class="dyn-source">
349
+ <pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 72</span>
350
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">program</span>
351
+ <span class="ruby-ivar">@compile</span>
352
+ <span class="ruby-keyword kw">end</span></pre>
353
+ </div>
354
+ </div>
355
+
356
+ </div>
357
+
358
+ <div class="method">
359
+ <div class="title" id="M000002">
360
+
361
+ <a name="M000002"></a><b>render</b>(context = TOPLEVEL_BINDING)
362
+
363
+ </div>
364
+
365
+ <div class="description">
366
+ <p>
367
+ Returns the result of executing the Ruby program for this template
368
+ (provided by the to_s() method) inside the given context binding.
369
+ </p>
370
+
371
+ </div>
372
+
373
+
374
+
375
+
376
+ <div class="sourcecode">
377
+ <p class="source-link">
378
+ Source: <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show</a>
379
+
380
+ </p>
381
+ <div id="M000002_source" class="dyn-source">
382
+ <pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 80</span>
383
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">context</span> = <span class="ruby-constant">TOPLEVEL_BINDING</span>)
384
+ <span class="ruby-identifier">eval</span> <span class="ruby-ivar">@compile</span>, <span class="ruby-identifier">context</span>,
385
+ (<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:source_file</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:SOURCE</span>).<span class="ruby-identifier">to_s</span>,
386
+ (<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:source_line</span>] <span class="ruby-operator">||</span> <span class="ruby-value">1</span>).<span class="ruby-identifier">to_i</span>
387
+ <span class="ruby-keyword kw">end</span></pre>
388
+ </div>
389
+ </div>
390
+
391
+ </div>
392
+
393
+ </div>
394
+ </div>
395
+ </body>
396
+ </html>