ember 0.0.1 → 0.1.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/HISTORY +79 -0
- data/INSTALL +31 -0
- data/MANUAL +25 -0
- data/README +54 -0
- data/THEORY +151 -0
- data/USAGE +250 -0
- data/bin/ember +58 -20
- data/doc/ann.xml +93 -0
- data/doc/api/Ember.html +436 -0
- data/doc/api/Ember/Template.html +774 -0
- data/doc/api/Ember/Template/Program.html +877 -0
- data/doc/api/Ember/Template/Program/Statement.html +181 -0
- data/doc/api/_index.html +139 -0
- data/doc/api/class_list.html +36 -0
- data/doc/api/css/common.css +1 -0
- data/doc/api/css/full_list.css +50 -0
- data/doc/api/css/style.css +273 -0
- data/doc/api/file.LICENSE.html +73 -0
- data/doc/api/file_list.html +38 -0
- data/doc/api/frames.html +13 -0
- data/doc/api/index.html +72 -13
- data/doc/api/js/app.js +111 -0
- data/doc/api/js/full_list.js +117 -0
- data/doc/api/js/{jquery-1.3.2.min.js → jquery.js} +0 -0
- data/doc/api/method_list.html +179 -0
- data/doc/api/top-level-namespace.html +87 -0
- data/doc/index.html +1353 -682
- data/inochi.opts +31 -0
- data/lib/ember.rb +1 -15
- data/lib/ember/inochi.rb +103 -0
- data/lib/ember/template.rb +66 -78
- data/test/combinatorics.rb +188 -0
- data/test/ember/template_test.rb +137 -0
- data/test/runner +25 -0
- data/test/test_helper.rb +5 -0
- metadata +61 -51
- data/doc/api/apple-touch-icon.png +0 -0
- data/doc/api/classes/Ember.html +0 -61
- data/doc/api/classes/Ember/Template.html +0 -413
- data/doc/api/classes/Ember/Template/Program.html +0 -60
- data/doc/api/created.rid +0 -1
- data/doc/api/css/main.css +0 -263
- data/doc/api/css/panel.css +0 -383
- data/doc/api/css/reset.css +0 -53
- data/doc/api/favicon.ico +0 -0
- data/doc/api/files/LICENSE.html +0 -76
- data/doc/api/files/lib/ember/template_rb.html +0 -66
- data/doc/api/files/lib/ember_rb.html +0 -63
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/js/jquery-effect.js +0 -593
- data/doc/api/js/main.js +0 -22
- data/doc/api/js/searchdoc.js +0 -628
- data/doc/api/panel/index.html +0 -71
- data/doc/api/panel/search_index.js +0 -1
- data/doc/api/panel/tree.js +0 -1
- data/doc/history.erb +0 -34
- data/doc/index.erb +0 -11
- data/doc/intro.erb +0 -53
- data/doc/setup.erb +0 -78
- data/doc/usage.erb +0 -280
- data/rakefile +0 -14
- data/test/ember.rb +0 -17
- data/test/ember/template.rb +0 -141
data/doc/api/panel/index.html
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
3
|
-
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
4
|
-
|
5
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
6
|
-
<head>
|
7
|
-
<title>layout</title>
|
8
|
-
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
-
<link rel="stylesheet" href="../css/panel.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
-
<script src="search_index.js" type="text/javascript" charset="utf-8"></script>
|
11
|
-
<script src="tree.js" type="text/javascript" charset="utf-8"></script>
|
12
|
-
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
13
|
-
<script src="../js/searchdoc.js" type="text/javascript" charset="utf-8"></script>
|
14
|
-
<script type="text/javascript" charset="utf-8">
|
15
|
-
//<![CDATA[
|
16
|
-
function placeholder() {
|
17
|
-
if (jQuery.browser.safari) return;
|
18
|
-
$('#search-label').click(function() {
|
19
|
-
$('#search').focus();
|
20
|
-
$('#search-label').hide();
|
21
|
-
});
|
22
|
-
|
23
|
-
$('#search').focus(function() {
|
24
|
-
$('#search-label').hide();
|
25
|
-
});
|
26
|
-
$('#search').blur(function() {
|
27
|
-
this.value == '' && $('#search-label').show()
|
28
|
-
});
|
29
|
-
|
30
|
-
$('#search')[0].value == '' && $('#search-label').show();
|
31
|
-
}
|
32
|
-
$(function() {
|
33
|
-
placeholder();
|
34
|
-
var panel = new Searchdoc.Panel($('#panel'), search_data, tree, top.frames[1]);
|
35
|
-
$('#search').focus();
|
36
|
-
|
37
|
-
var s = window.parent.location.search.match(/\?q=([^&]+)/);
|
38
|
-
if (s) {
|
39
|
-
s = decodeURIComponent(s[1]).replace(/\+/g, ' ');
|
40
|
-
if (s.length > 0)
|
41
|
-
{
|
42
|
-
$('#search').val(s);
|
43
|
-
panel.search(s, true);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
})
|
47
|
-
//]]>
|
48
|
-
</script>
|
49
|
-
</head>
|
50
|
-
<body>
|
51
|
-
<div class="panel panel_tree" id="panel">
|
52
|
-
<div class="header">
|
53
|
-
<div>
|
54
|
-
<label for="search" id="search-label" style="display: none">Search</label>
|
55
|
-
<table>
|
56
|
-
<tr><td>
|
57
|
-
<input type="Search" placeholder="Search" autosave="searchdoc" results="10" id="search" autocomplete="off"/>
|
58
|
-
</td></tr>
|
59
|
-
</table></div>
|
60
|
-
</div>
|
61
|
-
<div class="tree">
|
62
|
-
<ul>
|
63
|
-
</ul>
|
64
|
-
</div>
|
65
|
-
<div class="result">
|
66
|
-
<ul>
|
67
|
-
</ul>
|
68
|
-
</div>
|
69
|
-
</div>
|
70
|
-
</body>
|
71
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["ember","template","load_file()","new()","program()","read_file()","render()","license","ember.rb","template.rb"],"longSearchIndex":["lib/ember/template.rb","ember","ember::template","ember::template","ember::template","ember::template","ember::template","files/license.html","files/lib/ember_rb.html","files/lib/ember/template_rb.html"],"info":[["Ember","lib/ember/template.rb","classes/Ember.html"," < ","",1],["Template","Ember","classes/Ember/Template.html"," < Object","",1],["load_file","Ember::Template","classes/Ember/Template.html#M000003","(path, options = {})","Builds a template whose body is read from the given source. If the source is a relative path, it will",2],["new","Ember::Template","classes/Ember/Template.html#M000000","(input, options = {})","Builds a processor that evaluates eRuby directives in the given input according to the given options.",2],["program","Ember::Template","classes/Ember/Template.html#M000001","()","Ruby source code assembled from the eRuby template provided as input to the constructor of this class.",2],["read_file","Ember::Template","classes/Ember/Template.html#M000004","(path, options = {})","Returns the contents of the given file, which can be relative to the current template in which this command",2],["render","Ember::Template","classes/Ember/Template.html#M000002","(context = TOPLEVEL_BINDING, parent_context_id = nil)","Returns the result of executing the Ruby program for this template (provided by the #program() method)",2],["LICENSE","files/LICENSE.html","files/LICENSE.html","","(the ISC license) Copyright 2009 Suraj N. Kurapati <sunaku@gmail.com> Permission to use, copy, modify,",3],["ember.rb","files/lib/ember_rb.html","files/lib/ember_rb.html",""," ",3],["template.rb","files/lib/ember/template_rb.html","files/lib/ember/template_rb.html",""," ",3]]}}
|
data/doc/api/panel/tree.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
var tree = [["","","files",[["LICENSE","files/LICENSE.html","",[]],["","","lib",[["","","ember",[["template.rb","files/lib/ember/template_rb.html","",[]]]],["ember.rb","files/lib/ember_rb.html","",[]]]]]],["Ember","classes/Ember.html","",[["Template","classes/Ember/Template.html"," < Object",[]]]]]
|
data/doc/history.erb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
%#--
|
2
|
-
%# Copyright protects this work.
|
3
|
-
%# See LICENSE file for details.
|
4
|
-
%#++
|
5
|
-
|
6
|
-
|
7
|
-
%|chapter "History"
|
8
|
-
|
9
|
-
|
10
|
-
%|history
|
11
|
-
|
12
|
-
|
13
|
-
%|section "Version 0.0.1 (2009-10-03)"
|
14
|
-
|
15
|
-
This release improves Ruby 1.9 support and revises the user manual.
|
16
|
-
|
17
|
-
|
18
|
-
%|paragraph "Bug fixes"
|
19
|
-
|
20
|
-
* Nested templates could not access parent's binding in Ruby 1.9
|
21
|
-
|
22
|
-
|
23
|
-
%|paragraph "Housekeeping"
|
24
|
-
|
25
|
-
* Use simpler Copyright reminder at the top of every file.
|
26
|
-
|
27
|
-
* Rename internal `Program` class' methods to be self-documenting.
|
28
|
-
|
29
|
-
* Open source is for fun, so [be nice](http://loiclemeur.com/english/2009/03/never-criticize-your-competitors.html): speak of "related works" instead of "competitors".
|
30
|
-
|
31
|
-
|
32
|
-
%|section "Version 0.0.0 (2009-02-13)"
|
33
|
-
|
34
|
-
This is the first public release of <%= $project %>. Enjoy!
|
data/doc/index.erb
DELETED
data/doc/intro.erb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
%#--
|
2
|
-
%# Copyright protects this work.
|
3
|
-
%# See LICENSE file for details.
|
4
|
-
%#++
|
5
|
-
|
6
|
-
% api_url = './api/index.html'
|
7
|
-
% src_url = 'http://github.com/sunaku/' + $program
|
8
|
-
% src_scm = '[Git](http://git-scm.com)'
|
9
|
-
|
10
|
-
|
11
|
-
%|chapter "Introduction"
|
12
|
-
|
13
|
-
|
14
|
-
%|project
|
15
|
-
|
16
|
-
<%= $project %> is an [eRuby template](http://en.wikipedia.org/wiki/ERuby) processsor that allows debugging, reduces markup, and improves composability of eRuby templates.
|
17
|
-
|
18
|
-
|
19
|
-
* <%= xref "History", "What's new?" %> --- history of project releases.
|
20
|
-
* [Source code](<%= src_url %>) --- obtain via <%= src_scm %> or browse online.
|
21
|
-
* [API reference](<%= api_url %>) --- documentation for source code.
|
22
|
-
* [Project home](<%= $website %>) --- the <%= $project %> project home page.
|
23
|
-
|
24
|
-
To get help or provide feedback, simply
|
25
|
-
<%= xref "License", "contact the author(s)" %>.
|
26
|
-
|
27
|
-
|
28
|
-
%|section "Features"
|
29
|
-
|
30
|
-
<%= $project %> is exciting because:
|
31
|
-
* It reports correct line numbers in stack traces.
|
32
|
-
* It can infer <tt><%% end %></tt> based on indentation.
|
33
|
-
* It can unindent block content hierarchically.
|
34
|
-
* It completely silences code-only eRuby directives.
|
35
|
-
* It is implemented in <%= `sloccount lib`[/^\d+/] %> lines of pure Ruby.
|
36
|
-
|
37
|
-
|
38
|
-
%|section "Etymology"
|
39
|
-
|
40
|
-
<%= $project %> stands for *embe*dded *r*uby.
|
41
|
-
|
42
|
-
|
43
|
-
%|section "License"
|
44
|
-
|
45
|
-
%< "../LICENSE"
|
46
|
-
|
47
|
-
|
48
|
-
%|section "Related works"
|
49
|
-
|
50
|
-
* [Erubis](http://www.kuwata-lab.com/erubis/)
|
51
|
-
* [eruby](http://modruby.net/en/)
|
52
|
-
* [ERB](http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/)
|
53
|
-
|
data/doc/setup.erb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
%#--
|
2
|
-
%# Copyright protects this work.
|
3
|
-
%# See LICENSE file for details.
|
4
|
-
%#++
|
5
|
-
|
6
|
-
|
7
|
-
%|chapter "Setup"
|
8
|
-
|
9
|
-
|
10
|
-
%|section "Requirements"
|
11
|
-
|
12
|
-
Your system needs the following software to run <%= $project %>.
|
13
|
-
|
14
|
-
| Software | Description | Notes |
|
15
|
-
| -------- | ----------- | ----- |
|
16
|
-
| [Ruby](http://ruby-lang.org) | Ruby language interpreter | Version 1.8.6, 1.8.7, and 1.9.1 have been tested successfully. |
|
17
|
-
| [RubyGems](http://rubygems.org) | Ruby packaging system | Version 1.3.1 or newer is required. |
|
18
|
-
|
19
|
-
|
20
|
-
%|section "Installation"
|
21
|
-
|
22
|
-
You can install <%= $project %> by running this command:
|
23
|
-
|
24
|
-
gem install <%= $program %>
|
25
|
-
|
26
|
-
To check whether the installation was sucessful, run this command:
|
27
|
-
|
28
|
-
<%= $program %> --version
|
29
|
-
|
30
|
-
If the installation was successful, you will see output like this:
|
31
|
-
|
32
|
-
<pre><%= verbatim `ruby bin/#{$program} --version` %></pre>
|
33
|
-
|
34
|
-
If you do not see such output, you may
|
35
|
-
<%= xref "License", "ask the author(s)" %> for help.
|
36
|
-
|
37
|
-
|
38
|
-
%|section "Version numbers"
|
39
|
-
|
40
|
-
<%= $project %> releases are numbered in *major.minor.patch*
|
41
|
-
form according to the [RubyGems rational versioning
|
42
|
-
policy](http://www.rubygems.org/read/chapter/7), which
|
43
|
-
can be summarized thus:
|
44
|
-
|
45
|
-
<table markdown="1">
|
46
|
-
<thead>
|
47
|
-
<tr>
|
48
|
-
<td rowspan="2">What increased in the version number?</td>
|
49
|
-
<td colspan="3">The increase indicates that the release:</td>
|
50
|
-
</tr>
|
51
|
-
<tr>
|
52
|
-
<th>Is backward compatible?</th>
|
53
|
-
<th>Has new features?</th>
|
54
|
-
<th>Has bug fixes?</th>
|
55
|
-
</tr>
|
56
|
-
</thead>
|
57
|
-
<tbody>
|
58
|
-
<tr>
|
59
|
-
<th>major</th>
|
60
|
-
<td style="background-color: #FFE4E1;">No</td>
|
61
|
-
<td>Yes</td>
|
62
|
-
<td>Yes</td>
|
63
|
-
</tr>
|
64
|
-
<tr>
|
65
|
-
<th>minor</th>
|
66
|
-
<td>Yes</td>
|
67
|
-
<td>Yes</td>
|
68
|
-
<td>Yes</td>
|
69
|
-
</tr>
|
70
|
-
<tr>
|
71
|
-
<th>patch</th>
|
72
|
-
<td>Yes</td>
|
73
|
-
<td style="background-color: #FFE4E1;">No</td>
|
74
|
-
<td>Yes</td>
|
75
|
-
</tr>
|
76
|
-
</tbody>
|
77
|
-
</table>
|
78
|
-
|
data/doc/usage.erb
DELETED
@@ -1,280 +0,0 @@
|
|
1
|
-
%#--
|
2
|
-
%# Copyright protects this work.
|
3
|
-
%# See LICENSE file for details.
|
4
|
-
%#++
|
5
|
-
|
6
|
-
|
7
|
-
%|chapter "Usage"
|
8
|
-
|
9
|
-
|
10
|
-
%|section "Command-line interface"
|
11
|
-
|
12
|
-
When you run this command:
|
13
|
-
|
14
|
-
<%= $program %> --help
|
15
|
-
|
16
|
-
You will see this output:
|
17
|
-
|
18
|
-
<pre><%= verbatim `ruby bin/#{$program} --help` %></pre>
|
19
|
-
|
20
|
-
|
21
|
-
%|section "Ruby library interface"
|
22
|
-
|
23
|
-
Begin by loading <%= $project %> into Ruby:
|
24
|
-
|
25
|
-
<code>
|
26
|
-
require 'rubygems'
|
27
|
-
require '<%= $program %>'
|
28
|
-
</code>
|
29
|
-
|
30
|
-
Instantiate a template processor:
|
31
|
-
|
32
|
-
<code>
|
33
|
-
source = "your eRuby template here"
|
34
|
-
options = { :unindent => true, :shorthand => true }
|
35
|
-
|
36
|
-
template = Ember::Template.new(source, options)
|
37
|
-
</code>
|
38
|
-
|
39
|
-
Inspect the Ruby program that is used to evaluate the eRuby template:
|
40
|
-
|
41
|
-
<code>
|
42
|
-
puts template.program
|
43
|
-
</code>
|
44
|
-
|
45
|
-
View the result of evaluating the eRuby template:
|
46
|
-
|
47
|
-
<code>
|
48
|
-
puts template.render
|
49
|
-
</code>
|
50
|
-
|
51
|
-
See the [API documentation](<%= api_url %>) for details and examples.
|
52
|
-
|
53
|
-
|
54
|
-
%|section "eRuby template directives", "Directives"
|
55
|
-
|
56
|
-
eRuby templates are plain-text documents that contain special processing instructions known as **directives**. Directives may be expressed using either **standard** or **shorthand** notation:
|
57
|
-
|
58
|
-
| Notation | Directive | Head | Operation | Body | Tail |
|
59
|
-
| -------- | --------- | ---- | --------- | ---- | ---- |
|
60
|
-
| Standard | <%%XY%> | <%% | X | Y | %> |
|
61
|
-
| Shorthand | %XY | % | X | Y | |
|
62
|
-
|
63
|
-
In standard notation, the directive is composed of a head, <%= xref "Operations", "an operation" %>, a body, and a tail. Furthermore, the directive may appear anywhere in the text.
|
64
|
-
|
65
|
-
In shorthand notation, the directive is composed of a head, <%= xref "Operations", "an operation" %> and a body. Furthermore, the directive may only appear in the text if it occupies an entire line.
|
66
|
-
|
67
|
-
In any case, directives are atomic constructs; they may not be nested.
|
68
|
-
|
69
|
-
|
70
|
-
%|section "Operations"
|
71
|
-
|
72
|
-
The first character that follows the head of a directive is known as an **operation**. Operations specify how the directive should be processed:
|
73
|
-
|
74
|
-
| Operation | Effect | Example |
|
75
|
-
| --------- | ------ | ------- |
|
76
|
-
| <%= Ember::Template::OPERATION_COMMENT_LINE %> | The entire directive is omitted from the output. | <%= xref "Comment directives" %> |
|
77
|
-
| <%= Ember::Template::OPERATION_EVAL_EXPRESSION %> | The body of the directive is evaluated as Ruby code, and the result of this evaluation is inserted into the output. | <%= xref "Vocal directives" %> |
|
78
|
-
| <%= Ember::Template::OPERATION_EVAL_TEMPLATE_STRING %> | The body of the directive is evaluated as an eRuby template, and the result of this evaluation is inserted into the output. | <%= xref "Dynamic template evaluation" %> |
|
79
|
-
| <%= Ember::Template::OPERATION_EVAL_TEMPLATE_FILE %> | The body of the directive is evaluated as Ruby code, and the result of this evaluation is assumed to be a string that specifies the path (either absolute or relative to the eRuby template file in which this directive is found) to a file containing an eRuby template. This file is read and its contents are evaluated as an eRuby template, and the result of this evaluation is inserted into the output. | <%= xref "Template file inclusion" %> |
|
80
|
-
| <%= Ember::Template::OPERATION_INSERT_PLAIN_FILE %> | The body of the directive is evaluated as Ruby code, and the result of this evaluation is assumed to be a string that specifies the path (either absolute or relative to the eRuby template file in which this directive is found) to a file. This file is read and its contents are inserted into the output. | <%= xref "Raw file inclusion" %> |
|
81
|
-
| | | The body of the directive is treated as the beginning of a Ruby block. The `do` keyword is automatically appended to the body of the directive if missing. | <%= xref "Block directives" %> |
|
82
|
-
| % | One "%" character is omitted from the head of the directive and the entire directive is inserted into the output. | <%= xref "Escaped directives" %> |
|
83
|
-
| (none of the above) | The body of the directive is evaluated as Ruby code, but the result of this evaluation *is not* inserted into the output. | <%= xref "Silent directives" %> |
|
84
|
-
|
85
|
-
<%
|
86
|
-
standard_directive = lambda do |body|
|
87
|
-
'<' + '%' + body + ' %' + '>'
|
88
|
-
end
|
89
|
-
|
90
|
-
shorthand_directive = lambda do |body|
|
91
|
-
'%' + body
|
92
|
-
end
|
93
|
-
|
94
|
-
template_example = lambda do |input, options|
|
95
|
-
input = input.strip.gsub(/^ {4}/, '') << "\n" # remove indentation
|
96
|
-
template = Ember::Template.new(input, options)
|
97
|
-
|
98
|
-
options_display =
|
99
|
-
if options.empty?
|
100
|
-
"This"
|
101
|
-
else
|
102
|
-
"With `#{options.inspect}`, this"
|
103
|
-
end
|
104
|
-
|
105
|
-
[
|
106
|
-
"<pre>#{input}</pre>",
|
107
|
-
|
108
|
-
"#{options_display} template compiles into:",
|
109
|
-
"<code>#{template.program}</code>",
|
110
|
-
|
111
|
-
"And renders as:",
|
112
|
-
"<pre>#{template.render}</pre>",
|
113
|
-
|
114
|
-
].join("\n\n")
|
115
|
-
end
|
116
|
-
%>
|
117
|
-
|
118
|
-
|
119
|
-
%|example "An empty template"
|
120
|
-
|
121
|
-
Begin with an empty template:
|
122
|
-
|
123
|
-
%= template_example.call "", {}
|
124
|
-
|
125
|
-
|
126
|
-
%|example "Comment directives"
|
127
|
-
|
128
|
-
Add comment directives:
|
129
|
-
|
130
|
-
<%=
|
131
|
-
template_example.call %{
|
132
|
-
#{standard_directive['# this is a comment']}
|
133
|
-
#{shorthand_directive['# this is also a comment']}
|
134
|
-
|
135
|
-
#{standard_directive["# this is a\n\n multi-line comment"]}
|
136
|
-
}, :shorthand => true
|
137
|
-
%>
|
138
|
-
|
139
|
-
|
140
|
-
%|example "Escaped directives"
|
141
|
-
|
142
|
-
Add escaped directives:
|
143
|
-
|
144
|
-
<%=
|
145
|
-
example = '% this is an escaped directive'
|
146
|
-
|
147
|
-
template_example.call %{
|
148
|
-
#{standard_directive[example]}
|
149
|
-
#{shorthand_directive[example]}
|
150
|
-
}, :shorthand => true
|
151
|
-
%>
|
152
|
-
|
153
|
-
|
154
|
-
%|example "Vocal directives"
|
155
|
-
|
156
|
-
Add vocal directives, which produce output:
|
157
|
-
|
158
|
-
<%=
|
159
|
-
template_example.call %{
|
160
|
-
#{standard_directive['= "hello"']}
|
161
|
-
#{shorthand_directive['= "world"']}
|
162
|
-
|
163
|
-
}, :shorthand => true
|
164
|
-
%>
|
165
|
-
|
166
|
-
|
167
|
-
%|example "Silent directives"
|
168
|
-
|
169
|
-
Add silent directives, which do not produce output:
|
170
|
-
|
171
|
-
<%=
|
172
|
-
template_example.call %{
|
173
|
-
#{standard_directive[' a = "hello"']}
|
174
|
-
#{shorthand_directive[' b = "world"']}
|
175
|
-
|
176
|
-
#{standard_directive['= a']}
|
177
|
-
#{shorthand_directive['= b']}
|
178
|
-
|
179
|
-
}, :shorthand => true
|
180
|
-
%>
|
181
|
-
|
182
|
-
|
183
|
-
%|example "Block directives"
|
184
|
-
|
185
|
-
Add some Ruby blocks:
|
186
|
-
|
187
|
-
<%=
|
188
|
-
template_example.call %{
|
189
|
-
#{shorthand_directive[' words = %w[hello world]']}
|
190
|
-
|
191
|
-
#{standard_directive[' words.each do |w|']}
|
192
|
-
#{standard_directive['= w']}
|
193
|
-
#{standard_directive[' end']}
|
194
|
-
|
195
|
-
#{shorthand_directive[' words.each do |w|']}
|
196
|
-
#{shorthand_directive['= w']}
|
197
|
-
#{shorthand_directive[' end']}
|
198
|
-
|
199
|
-
#{shorthand_directive['|words.each |w|']}
|
200
|
-
#{shorthand_directive['= w']}
|
201
|
-
#{shorthand_directive[' end']}
|
202
|
-
|
203
|
-
}, :shorthand => true
|
204
|
-
%>
|
205
|
-
|
206
|
-
|
207
|
-
%|example "Infer block endings"
|
208
|
-
|
209
|
-
Omit <tt><%= standard_directive[' end'] %></tt> directives from the template:
|
210
|
-
|
211
|
-
<%=
|
212
|
-
template_example.call %{
|
213
|
-
#{shorthand_directive[' words = %w[hello world]']}
|
214
|
-
|
215
|
-
#{standard_directive[' words.each do |w|']}
|
216
|
-
#{standard_directive['= w']}
|
217
|
-
|
218
|
-
#{shorthand_directive[' words.each do |w|']}
|
219
|
-
#{shorthand_directive['= w']}
|
220
|
-
|
221
|
-
#{shorthand_directive['|words.each |w|']}
|
222
|
-
#{shorthand_directive['= w']}
|
223
|
-
|
224
|
-
}, :shorthand => true, :infer_end => true
|
225
|
-
%>
|
226
|
-
|
227
|
-
|
228
|
-
%|example "Raw file inclusion"
|
229
|
-
|
230
|
-
When <tt>doc/example.txt</tt> contains:
|
231
|
-
|
232
|
-
<pre><%< "example.txt" %></pre>
|
233
|
-
|
234
|
-
And the eRuby template is:
|
235
|
-
|
236
|
-
<%=
|
237
|
-
example = '< "example.txt"'
|
238
|
-
|
239
|
-
template_example.call %{
|
240
|
-
#{standard_directive[example]}
|
241
|
-
|
242
|
-
#{shorthand_directive[example]}
|
243
|
-
|
244
|
-
}, :shorthand => true, :source_file => __FILE__
|
245
|
-
%>
|
246
|
-
|
247
|
-
|
248
|
-
%|example "Template file inclusion"
|
249
|
-
|
250
|
-
When <tt>doc/example.erb</tt> contains:
|
251
|
-
|
252
|
-
<code lang="rhtml"><%< "example.erb" %></code>
|
253
|
-
|
254
|
-
And the eRuby template is:
|
255
|
-
|
256
|
-
<%=
|
257
|
-
example = '+ "example.erb"'
|
258
|
-
|
259
|
-
template_example.call %{
|
260
|
-
#{standard_directive[example]}
|
261
|
-
|
262
|
-
#{shorthand_directive[example]}
|
263
|
-
|
264
|
-
}, :shorthand => true, :source_file => __FILE__
|
265
|
-
%>
|
266
|
-
|
267
|
-
|
268
|
-
%|example "Dynamic template evaluation"
|
269
|
-
|
270
|
-
<%=
|
271
|
-
example = %{~ "#{shorthand_directive['= 2 + 2']}"}
|
272
|
-
|
273
|
-
template_example.call %{
|
274
|
-
#{standard_directive[example]}
|
275
|
-
|
276
|
-
#{shorthand_directive[example]}
|
277
|
-
|
278
|
-
}, :shorthand => true
|
279
|
-
%>
|
280
|
-
|