ember 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'ember/template'
|
2
|
+
|
3
|
+
describe do
|
4
|
+
BLANK = [''] # the empty string
|
5
|
+
NEWLINES = ["\n", "\r\n"]
|
6
|
+
SPACES = [' ', "\t"]
|
7
|
+
WHITESPACE = SPACES + NEWLINES
|
8
|
+
OPERATIONS = [nil, '=', '#', *WHITESPACE]
|
9
|
+
|
10
|
+
##
|
11
|
+
# Invokes the given block, passing in the result
|
12
|
+
# of Array#join, for every possible combination.
|
13
|
+
#
|
14
|
+
def each_join array
|
15
|
+
raise ArgumentError unless block_given?
|
16
|
+
|
17
|
+
array.permutations do |combo|
|
18
|
+
yield combo.join
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "A template" do
|
23
|
+
it "renders single & multi-line comments as nothing" do
|
24
|
+
each_join(WHITESPACE) do |s|
|
25
|
+
render("<%##{s}an#{s}eRuby#{s}comment#{s}%>").must_equal("")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "renders directives with whitespace-only bodies as nothing" do
|
30
|
+
each_join(WHITESPACE) do |s|
|
31
|
+
OPERATIONS.each do |o|
|
32
|
+
render("<%#{o}#{s}%>").must_equal("")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "renders escaped directives in unescaped form" do
|
38
|
+
render("<%%%>").must_equal("<%%>")
|
39
|
+
|
40
|
+
render("<%% %>").must_equal("<% %>")
|
41
|
+
|
42
|
+
E SyntaxError, "the trailing delimiter must not be unescaped" do
|
43
|
+
render("<% %%>")
|
44
|
+
end
|
45
|
+
|
46
|
+
render("<%%%%>").must_equal("<%%%>",
|
47
|
+
"the trailing delimiter must not be unescaped")
|
48
|
+
|
49
|
+
each_join(WHITESPACE) do |s|
|
50
|
+
body = "#{s}an#{s}eRuby#{s}directive#{s}"
|
51
|
+
|
52
|
+
OPERATIONS.each do |o|
|
53
|
+
render("<%%#{o}#{body}%>").must_equal("<%#{o}#{body}%>")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "renders whitespace surrounding vocal directives correctly" do
|
59
|
+
o = rand.to_s
|
60
|
+
i = "<%= #{o} %>"
|
61
|
+
|
62
|
+
each_join(WHITESPACE) do |s|
|
63
|
+
(BLANK + NEWLINES).enumeration do |a, b|
|
64
|
+
render("a#{a}#{s}#{i}#{b}#{s}b").must_equal("a#{a}#{s}#{o}#{b}#{s}b")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "renders whitespace surrounding silent directives correctly" do
|
70
|
+
i = '<%%>'
|
71
|
+
o = ''
|
72
|
+
|
73
|
+
each_join(SPACES) do |s|
|
74
|
+
NEWLINES.each do |n|
|
75
|
+
# without preceding newline
|
76
|
+
render("a#{s}#{i}#{n}b").must_equal("a#{o}b")
|
77
|
+
|
78
|
+
# with preceding newline
|
79
|
+
render("a#{n}#{s}#{i}#{n}b").must_equal("a#{n}#{o}b")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def render input, options = {}
|
85
|
+
Ember::Template.new(input, options).render
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "A program compiled from a template" do
|
90
|
+
it "has the same number of lines as its input, regardless of template options" do
|
91
|
+
(BLANK + NEWLINES).each do |s|
|
92
|
+
test_num_lines s
|
93
|
+
test_num_lines "hello#{s}world"
|
94
|
+
|
95
|
+
OPERATIONS.each do |o|
|
96
|
+
test_num_lines "<%#{o}hello#{s}world%>"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
OPTIONS = [:shorthand, :infer_end, :unindent]
|
102
|
+
|
103
|
+
##
|
104
|
+
# Checks that the given input template is compiled into the same
|
105
|
+
# number of lines of Ruby code for all possible template options.
|
106
|
+
#
|
107
|
+
def test_num_lines input
|
108
|
+
num_input_lines = count_lines(input)
|
109
|
+
|
110
|
+
each_option_combo(OPTIONS) do |options|
|
111
|
+
template = Ember::Template.new(input, options)
|
112
|
+
program = template.program
|
113
|
+
|
114
|
+
count_lines(program).must_equal num_input_lines, "template program compiled with #{options.inspect} has different number of lines for input #{input.inspect}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Counts the number of lines in the given string.
|
120
|
+
#
|
121
|
+
def count_lines string
|
122
|
+
string.to_s.scan(/$/).length
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# Invokes the given block, passing in an options hash
|
127
|
+
# for Ember::Template, for every possible combination.
|
128
|
+
#
|
129
|
+
def each_option_combo options
|
130
|
+
raise ArgumentError unless block_given?
|
131
|
+
|
132
|
+
options.combinations do |flags|
|
133
|
+
yield Hash[ *flags.map {|f| [f, true] }.flatten ]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/test/runner
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Adds the project library directory
|
4
|
+
# and this test directory to Ruby's
|
5
|
+
# load path and runs the given tests.
|
6
|
+
#
|
7
|
+
# Usage: ruby test/runner [TESTS_TO_RUN]
|
8
|
+
#
|
9
|
+
# Where: TESTS_TO_RUN is a list of files
|
10
|
+
# or file globbing patterns that
|
11
|
+
# describe a set of files to run.
|
12
|
+
#
|
13
|
+
# If this parameter is not given,
|
14
|
+
# all *_test.rb files within or
|
15
|
+
# beneath this directory are run.
|
16
|
+
|
17
|
+
lib_dir = File.expand_path('../../lib', __FILE__)
|
18
|
+
test_dir = File.expand_path('..', __FILE__)
|
19
|
+
$LOAD_PATH.unshift lib_dir, test_dir
|
20
|
+
|
21
|
+
require 'ember/inochi'
|
22
|
+
require 'test_helper'
|
23
|
+
|
24
|
+
ARGV << "#{test_dir}/**/*_test.rb" if ARGV.empty?
|
25
|
+
ARGV.each {|glob| Dir[glob].each {|test| load test } }
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Suraj N. Kurapati
|
@@ -9,33 +14,36 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-03 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: inochi
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ~>
|
22
26
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
version: "2"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
name: dfect
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ~>
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
segments:
|
40
|
+
- 2
|
41
|
+
version: "2"
|
42
|
+
type: :development
|
43
|
+
version_requirements: *id002
|
44
|
+
description: " Ember (EMBEdded Ruby) is an [1]eRuby template processor that\n enables debugging, reduces markup, and improves composability\n of eRuby templates.\n\n * It reports correct line numbers in error message stack\n traces.\n\n * It can infer <% end %> based on indentation.\n\n * It can unindent block content hierarchically.\n\n * It completely silences code-only eRuby directives.\n\n * It is implemented in 364 lines of pure Ruby.\n\n\
|
45
|
+
References\n\n 1. http://en.wikipedia.org/wiki/ERuby\n"
|
46
|
+
email:
|
39
47
|
executables:
|
40
48
|
- ember
|
41
49
|
extensions: []
|
@@ -43,46 +51,46 @@ extensions: []
|
|
43
51
|
extra_rdoc_files: []
|
44
52
|
|
45
53
|
files:
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
54
|
+
- THEORY
|
55
|
+
- inochi.opts
|
56
|
+
- INSTALL
|
57
|
+
- MANUAL
|
58
|
+
- test/combinatorics.rb
|
59
|
+
- test/ember/template_test.rb
|
60
|
+
- test/runner
|
61
|
+
- test/test_helper.rb
|
49
62
|
- lib/ember.rb
|
63
|
+
- lib/ember/inochi.rb
|
50
64
|
- lib/ember/template.rb
|
51
65
|
- bin/ember
|
66
|
+
- USAGE
|
52
67
|
- LICENSE
|
53
|
-
-
|
54
|
-
-
|
68
|
+
- HISTORY
|
69
|
+
- README
|
70
|
+
- doc/ann.xml
|
55
71
|
- doc/example.txt
|
56
72
|
- doc/example.erb
|
57
73
|
- doc/index.html
|
58
|
-
- doc/api/
|
59
|
-
- doc/api/
|
60
|
-
- doc/api/
|
61
|
-
- doc/api/
|
62
|
-
- doc/api/
|
63
|
-
- doc/api/
|
64
|
-
- doc/api/
|
65
|
-
- doc/api/
|
66
|
-
- doc/api/
|
67
|
-
- doc/api/
|
68
|
-
- doc/api/
|
69
|
-
- doc/api/
|
70
|
-
- doc/api/
|
71
|
-
- doc/api/
|
72
|
-
- doc/api/
|
73
|
-
- doc/api/css/panel.css
|
74
|
-
- doc/api/i/arrows.png
|
75
|
-
- doc/api/i/tree_bg.png
|
76
|
-
- doc/api/i/results_bg.png
|
77
|
-
- doc/api/apple-touch-icon.png
|
78
|
-
- doc/api/created.rid
|
79
|
-
- doc/api/favicon.ico
|
74
|
+
- doc/api/Ember.html
|
75
|
+
- doc/api/class_list.html
|
76
|
+
- doc/api/js/full_list.js
|
77
|
+
- doc/api/js/jquery.js
|
78
|
+
- doc/api/js/app.js
|
79
|
+
- doc/api/method_list.html
|
80
|
+
- doc/api/Ember/Template/Program.html
|
81
|
+
- doc/api/Ember/Template/Program/Statement.html
|
82
|
+
- doc/api/Ember/Template.html
|
83
|
+
- doc/api/css/full_list.css
|
84
|
+
- doc/api/css/style.css
|
85
|
+
- doc/api/css/common.css
|
86
|
+
- doc/api/_index.html
|
87
|
+
- doc/api/frames.html
|
88
|
+
- doc/api/top-level-namespace.html
|
80
89
|
- doc/api/index.html
|
90
|
+
- doc/api/file.LICENSE.html
|
91
|
+
- doc/api/file_list.html
|
81
92
|
- doc/ember.png
|
82
|
-
- doc/usage.erb
|
83
|
-
- doc/history.erb
|
84
93
|
- doc/ember.svg
|
85
|
-
- doc/index.erb
|
86
94
|
has_rdoc: true
|
87
95
|
homepage: http://snk.tuxfamily.org/lib/ember/
|
88
96
|
licenses: []
|
@@ -96,18 +104,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
104
|
requirements:
|
97
105
|
- - ">="
|
98
106
|
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
99
109
|
version: "0"
|
100
|
-
version:
|
101
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
111
|
requirements:
|
103
112
|
- - ">="
|
104
113
|
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
105
116
|
version: "0"
|
106
|
-
version:
|
107
117
|
requirements: []
|
108
118
|
|
109
|
-
rubyforge_project:
|
110
|
-
rubygems_version: 1.3.
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.3.6
|
111
121
|
signing_key:
|
112
122
|
specification_version: 3
|
113
123
|
summary: eRuby template processor
|
Binary file
|
data/doc/api/classes/Ember.html
DELETED
@@ -1,61 +0,0 @@
|
|
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>
|
@@ -1,413 +0,0 @@
|
|
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"><
|
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">'<'</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
|
-
| <a href="http://github.com/sunaku/ember/blob/f6b6ad4d02813bfe061fe18469d2d20395699d65/lib/ember/template.rb#L103" target="_blank" class="github_url">on GitHub</a>
|
182
|
-
|
183
|
-
</p>
|
184
|
-
<div id="M000003_source" class="dyn-source">
|
185
|
-
<pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 103</span>
|
186
|
-
<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> = {}
|
187
|
-
<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>)
|
188
|
-
<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">></span> <span class="ruby-identifier">path</span>)
|
189
|
-
<span class="ruby-keyword kw">end</span></pre>
|
190
|
-
</div>
|
191
|
-
</div>
|
192
|
-
|
193
|
-
</div>
|
194
|
-
|
195
|
-
<div class="method">
|
196
|
-
<div class="title" id="M000000">
|
197
|
-
|
198
|
-
<a name="M000000"></a><b>new</b>(input, options = {})
|
199
|
-
|
200
|
-
</div>
|
201
|
-
|
202
|
-
<div class="description">
|
203
|
-
<p>
|
204
|
-
Builds a processor that evaluates eRuby directives in the given input
|
205
|
-
according to the given options.
|
206
|
-
</p>
|
207
|
-
<p>
|
208
|
-
This processor transforms the given input into an executable Ruby program
|
209
|
-
(provided by the program() method) which is then executed by the render()
|
210
|
-
method on demand.
|
211
|
-
</p>
|
212
|
-
<p>
|
213
|
-
eRuby directives that contribute to the output of the given template are
|
214
|
-
called “vocal” directives. Those that do not are called
|
215
|
-
“silent” directives.
|
216
|
-
</p>
|
217
|
-
<h4>Options</h4>
|
218
|
-
<dl>
|
219
|
-
<dt>:result_variable</dt><dd>Name of the variable which stores the result of template evaluation during
|
220
|
-
template evaluation.
|
221
|
-
|
222
|
-
<p>
|
223
|
-
The default value is “_erbout”.
|
224
|
-
</p>
|
225
|
-
</dd>
|
226
|
-
<dt>:continue_result</dt><dd>Append to the result variable if it already exists?
|
227
|
-
|
228
|
-
<p>
|
229
|
-
The default value is false.
|
230
|
-
</p>
|
231
|
-
</dd>
|
232
|
-
<dt>:source_file</dt><dd>Name of the file which contains the given input. This is shown in stack
|
233
|
-
traces when reporting error messages.
|
234
|
-
|
235
|
-
<p>
|
236
|
-
The default value is “SOURCE”.
|
237
|
-
</p>
|
238
|
-
</dd>
|
239
|
-
<dt>:source_line</dt><dd>Line number at which the given input exists in the :source_file. This is
|
240
|
-
shown in stack traces when reporting error messages.
|
241
|
-
|
242
|
-
<p>
|
243
|
-
The default value is 1.
|
244
|
-
</p>
|
245
|
-
</dd>
|
246
|
-
<dt>:shorthand</dt><dd>Treat lines beginning with “%” as eRuby directives?
|
247
|
-
|
248
|
-
<p>
|
249
|
-
The default value is false.
|
250
|
-
</p>
|
251
|
-
</dd>
|
252
|
-
<dt>:<a href="Template.html#M000009">infer_end</a></dt><dd>Add missing <% end %> statements based on indentation?
|
253
|
-
|
254
|
-
<p>
|
255
|
-
The default value is false.
|
256
|
-
</p>
|
257
|
-
</dd>
|
258
|
-
<dt>:unindent</dt><dd>Unindent the content of eRuby blocks (everything between <% do %> …
|
259
|
-
<% end %>) hierarchically?
|
260
|
-
|
261
|
-
<p>
|
262
|
-
The default value is false.
|
263
|
-
</p>
|
264
|
-
</dd>
|
265
|
-
</dl>
|
266
|
-
|
267
|
-
</div>
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
<div class="sourcecode">
|
273
|
-
<p class="source-link">
|
274
|
-
Source: <a href="javascript:toggleSource('M000000_source')" id="l_M000000_source">show</a>
|
275
|
-
|
276
|
-
| <a href="http://github.com/sunaku/ember/blob/f6b6ad4d02813bfe061fe18469d2d20395699d65/lib/ember/template.rb#L64" target="_blank" class="github_url">on GitHub</a>
|
277
|
-
|
278
|
-
</p>
|
279
|
-
<div id="M000000_source" class="dyn-source">
|
280
|
-
<pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 64</span>
|
281
|
-
<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> = {}
|
282
|
-
<span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
|
283
|
-
<span class="ruby-ivar">@render_context_id</span> = <span class="ruby-identifier">object_id</span>
|
284
|
-
<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>)
|
285
|
-
<span class="ruby-keyword kw">end</span></pre>
|
286
|
-
</div>
|
287
|
-
</div>
|
288
|
-
|
289
|
-
</div>
|
290
|
-
|
291
|
-
<div class="method">
|
292
|
-
<div class="title" id="M000004">
|
293
|
-
|
294
|
-
<a name="M000004"></a><b>read_file</b>(path, options = {})
|
295
|
-
|
296
|
-
</div>
|
297
|
-
|
298
|
-
<div class="description">
|
299
|
-
<p>
|
300
|
-
Returns the contents of the given file, which can be relative to the
|
301
|
-
current template in which this command is being executed.
|
302
|
-
</p>
|
303
|
-
<p>
|
304
|
-
If the source is a relative path, it will be resolved relative to
|
305
|
-
options[:source_file] if that is a valid path.
|
306
|
-
</p>
|
307
|
-
|
308
|
-
</div>
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
<div class="sourcecode">
|
314
|
-
<p class="source-link">
|
315
|
-
Source: <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show</a>
|
316
|
-
|
317
|
-
| <a href="http://github.com/sunaku/ember/blob/f6b6ad4d02813bfe061fe18469d2d20395699d65/lib/ember/template.rb#L115" target="_blank" class="github_url">on GitHub</a>
|
318
|
-
|
319
|
-
</p>
|
320
|
-
<div id="M000004_source" class="dyn-source">
|
321
|
-
<pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 115</span>
|
322
|
-
<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> = {}
|
323
|
-
<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>)
|
324
|
-
<span class="ruby-keyword kw">end</span></pre>
|
325
|
-
</div>
|
326
|
-
</div>
|
327
|
-
|
328
|
-
</div>
|
329
|
-
|
330
|
-
<div class="sectiontitle">Instance Public methods</div>
|
331
|
-
|
332
|
-
<div class="method">
|
333
|
-
<div class="title" id="M000001">
|
334
|
-
|
335
|
-
<a name="M000001"></a><b>program</b>()
|
336
|
-
|
337
|
-
</div>
|
338
|
-
|
339
|
-
<div class="description">
|
340
|
-
<p>
|
341
|
-
Ruby source code assembled from the eRuby template provided as input to the
|
342
|
-
constructor of this class.
|
343
|
-
</p>
|
344
|
-
|
345
|
-
</div>
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
<div class="sourcecode">
|
351
|
-
<p class="source-link">
|
352
|
-
Source: <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show</a>
|
353
|
-
|
354
|
-
| <a href="http://github.com/sunaku/ember/blob/f6b6ad4d02813bfe061fe18469d2d20395699d65/lib/ember/template.rb#L74" target="_blank" class="github_url">on GitHub</a>
|
355
|
-
|
356
|
-
</p>
|
357
|
-
<div id="M000001_source" class="dyn-source">
|
358
|
-
<pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 74</span>
|
359
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">program</span>
|
360
|
-
<span class="ruby-ivar">@compile</span>
|
361
|
-
<span class="ruby-keyword kw">end</span></pre>
|
362
|
-
</div>
|
363
|
-
</div>
|
364
|
-
|
365
|
-
</div>
|
366
|
-
|
367
|
-
<div class="method">
|
368
|
-
<div class="title" id="M000002">
|
369
|
-
|
370
|
-
<a name="M000002"></a><b>render</b>(context = TOPLEVEL_BINDING, parent_context_id = nil)
|
371
|
-
|
372
|
-
</div>
|
373
|
-
|
374
|
-
<div class="description">
|
375
|
-
<p>
|
376
|
-
Returns the result of executing the Ruby program for this template
|
377
|
-
(provided by the program() method) inside the given context binding.
|
378
|
-
</p>
|
379
|
-
|
380
|
-
</div>
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
<div class="sourcecode">
|
386
|
-
<p class="source-link">
|
387
|
-
Source: <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show</a>
|
388
|
-
|
389
|
-
| <a href="http://github.com/sunaku/ember/blob/f6b6ad4d02813bfe061fe18469d2d20395699d65/lib/ember/template.rb#L84" target="_blank" class="github_url">on GitHub</a>
|
390
|
-
|
391
|
-
</p>
|
392
|
-
<div id="M000002_source" class="dyn-source">
|
393
|
-
<pre><span class="ruby-comment cmt"># File lib/ember/template.rb, line 84</span>
|
394
|
-
<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>, <span class="ruby-identifier">parent_context_id</span> = <span class="ruby-keyword kw">nil</span>
|
395
|
-
<span class="ruby-identifier">context</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@@contexts</span>[<span class="ruby-identifier">parent_context_id</span>] <span class="ruby-comment cmt"># inherit parent context</span>
|
396
|
-
<span class="ruby-ivar">@@contexts</span>[<span class="ruby-ivar">@render_context_id</span>] = <span class="ruby-identifier">context</span> <span class="ruby-comment cmt"># provide to children</span>
|
397
|
-
|
398
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">eval</span> <span class="ruby-ivar">@compile</span>, <span class="ruby-identifier">context</span>,
|
399
|
-
(<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>,
|
400
|
-
(<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>
|
401
|
-
|
402
|
-
<span class="ruby-ivar">@@contexts</span>.<span class="ruby-identifier">delete</span> <span class="ruby-ivar">@render_context_id</span> <span class="ruby-comment cmt"># free the memory</span>
|
403
|
-
<span class="ruby-identifier">result</span>
|
404
|
-
<span class="ruby-keyword kw">end</span></pre>
|
405
|
-
</div>
|
406
|
-
</div>
|
407
|
-
|
408
|
-
</div>
|
409
|
-
|
410
|
-
</div>
|
411
|
-
</div>
|
412
|
-
</body>
|
413
|
-
</html>
|