undies 3.0.0.rc.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -3
- data/Gemfile +7 -4
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.md +107 -105
- data/Rakefile +1 -8
- data/lib/undies/api.rb +2 -1
- data/lib/undies/element.rb +43 -81
- data/lib/undies/element_node.rb +6 -5
- data/lib/undies/io.rb +0 -1
- data/lib/undies/raw.rb +15 -0
- data/lib/undies/source.rb +0 -8
- data/lib/undies/version.rb +1 -1
- data/lib/undies.rb +4 -2
- data/test/helper.rb +5 -85
- data/test/support/element.rb +79 -0
- data/test/{templates → support/templates}/content.html.rb +0 -0
- data/test/{templates → support/templates}/index.html.rb +0 -0
- data/test/{templates → support/templates}/layout.html.rb +0 -0
- data/test/{templates → support/templates}/test.html.rb +0 -0
- data/test/{element_closed_test.rb → unit/element_closed_tests.rb} +2 -6
- data/test/{element_node_test.rb → unit/element_node_tests.rb} +5 -11
- data/test/{element_open_test.rb → unit/element_open_tests.rb} +2 -5
- data/test/{element_test.rb → unit/element_tests.rb} +1 -2
- data/test/{io_test.rb → unit/io_tests.rb} +3 -8
- data/test/{named_source_test.rb → unit/named_source_tests.rb} +4 -5
- data/test/{raw_test.rb → unit/raw_tests.rb} +6 -5
- data/test/{root_node_test.rb → unit/root_node_tests.rb} +4 -3
- data/test/{source_stack_test.rb → unit/source_stack_tests.rb} +2 -3
- data/test/{source_test.rb → unit/source_tests.rb} +5 -6
- data/test/{template_builder_render_test.rb → unit/template_builder_render_tests.rb} +3 -0
- data/test/{template_source_render_test.rb → unit/template_source_render_tests.rb} +5 -10
- data/test/{template_test.rb → unit/template_tests.rb} +12 -30
- data/undies.gemspec +16 -18
- metadata +58 -111
- data/Gemfile.lock +0 -48
- data/test/fixtures/write_thing.rb +0 -21
- data/test/irb.rb +0 -9
data/.gitignore
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
-
pkg/*
|
2
|
-
.bundle
|
3
1
|
*.gem
|
4
2
|
*.log
|
5
|
-
|
3
|
+
*.rbc
|
4
|
+
.rbx/
|
5
|
+
.bundle
|
6
|
+
.config
|
7
|
+
.yardoc
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
6
20
|
|
7
21
|
bench/*.txt
|
data/Gemfile
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
# Specify dependencies in undies.gemspec
|
4
3
|
gemspec
|
5
4
|
|
6
|
-
gem 'rake'
|
5
|
+
gem 'rake'
|
6
|
+
gem 'pry'
|
7
|
+
|
7
8
|
gem 'ruby-prof'
|
9
|
+
gem 'whysoslow'
|
10
|
+
gem 'ansi'
|
11
|
+
|
8
12
|
gem 'erubis'
|
9
13
|
gem 'haml'
|
10
14
|
gem 'markaby'
|
11
15
|
gem 'erector'
|
12
|
-
gem 'ansi'
|
data/{LICENSE → LICENSE.txt}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -18,47 +18,49 @@ Or install it yourself as:
|
|
18
18
|
## Usage
|
19
19
|
|
20
20
|
```ruby
|
21
|
+
_ raw "<!DOCTYPE html>"
|
21
22
|
_html {
|
22
23
|
_head {
|
23
24
|
_title "Hello World"
|
24
25
|
}
|
25
26
|
body {
|
26
27
|
_h1.main!.big "Hi There!"
|
27
|
-
_p "this is
|
28
|
+
_p "this is a hello world & ", em("Undies"), " usage example."
|
28
29
|
}
|
29
30
|
}
|
30
31
|
```
|
31
32
|
|
32
33
|
Will stream out
|
33
34
|
|
34
|
-
```
|
35
|
+
``` html
|
36
|
+
<!DOCTYPE html>
|
35
37
|
<html>
|
36
38
|
<head>
|
37
39
|
<title>Hello World</title>
|
38
40
|
</head>
|
39
41
|
<body>
|
40
42
|
<h1 class="big" id="main">Hi There!</h1>
|
41
|
-
<p>this is
|
43
|
+
<p>this is a hello world & <em>Undies</em> usage example.</p>
|
42
44
|
</body>
|
43
45
|
</html>
|
44
46
|
```
|
45
47
|
|
46
|
-
##
|
48
|
+
## Captured Output
|
47
49
|
|
48
50
|
### Plain text
|
49
51
|
|
50
52
|
All text is escaped by default.
|
51
53
|
|
52
54
|
```ruby
|
53
|
-
|
54
|
-
|
55
|
+
Undies::Template.escape_html("ab&<>'\"/yz")
|
56
|
+
# => "ab&<>'"/yz"
|
55
57
|
```
|
56
58
|
|
57
59
|
Capture raw (un-escaped) text using the `raw` method
|
58
60
|
|
59
61
|
```ruby
|
60
|
-
|
61
|
-
|
62
|
+
raw "this will <em>not</em> be escaped"
|
63
|
+
# => "this will <em>not</em> be escaped"
|
62
64
|
```
|
63
65
|
|
64
66
|
### XML
|
@@ -66,48 +68,48 @@ Capture raw (un-escaped) text using the `raw` method
|
|
66
68
|
Capture an empty element:
|
67
69
|
|
68
70
|
```ruby
|
69
|
-
|
70
|
-
|
71
|
+
element(:thing) # => "<thing />"
|
72
|
+
|
73
|
+
# use `tag` as an alias to `element`
|
74
|
+
tag('ns:thing') # => "<ns:thing />"
|
71
75
|
```
|
72
76
|
|
73
77
|
Capture an element with content:
|
74
78
|
|
75
79
|
```ruby
|
76
|
-
|
77
|
-
|
78
|
-
element(:thing, "some content")
|
79
|
-
# => "<thing>some content</thing>"
|
80
|
-
|
81
|
-
# all content is escaped by default
|
80
|
+
# basic content
|
82
81
|
|
83
|
-
|
84
|
-
|
82
|
+
element(:thing, "some content")
|
83
|
+
# => "<thing>some content</thing>"
|
85
84
|
|
86
|
-
|
85
|
+
# all content is escaped by default
|
86
|
+
element(:thing, "&<>")
|
87
|
+
# => "<thing>&<></thing>"
|
87
88
|
|
88
|
-
|
89
|
-
|
89
|
+
# you can force raw content using the `raw` method
|
90
|
+
element(:thing, raw("<raw>text</raw>"))
|
91
|
+
# => "<thing><raw>text</raw></thing>"
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
# => "<thing>1 < 2<raw>text</raw>& 4 > 3</thing>"
|
93
|
+
# you can pass in as many pieces of content as you like
|
94
|
+
element(:thing, "1 < 2", raw("<raw>text</raw>"), " & 4 > 3")
|
95
|
+
# => "<thing>1 < 2<raw>text</raw>& 4 > 3</thing>"
|
95
96
|
```
|
96
97
|
|
97
98
|
Capture an element with attributes:
|
98
99
|
|
99
100
|
```ruby
|
100
|
-
|
101
|
-
|
101
|
+
element(:thing, "some content", :one => 1, 'a' => "Aye")
|
102
|
+
# => "<thing one=\"1\" a=\"Aye\">some content</thing>"
|
102
103
|
```
|
103
104
|
|
104
105
|
Capture nested elements:
|
105
106
|
|
106
107
|
```ruby
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
108
|
+
element(
|
109
|
+
:thing,
|
110
|
+
element('Something', "Some Content"),
|
111
|
+
element('AnotherThing', "more content")
|
112
|
+
) # => "<thing><Something>Some Content</Something><AnotherThing>more content</AnotherThing></thing>"
|
111
113
|
```
|
112
114
|
|
113
115
|
### HTML
|
@@ -115,54 +117,52 @@ Capture nested elements:
|
|
115
117
|
In general, all the same stuff applies. However, you can call specific methods for all non-deprecated elements from the HTML 4.0.1 spec.
|
116
118
|
|
117
119
|
```ruby
|
118
|
-
|
119
|
-
|
120
|
+
br
|
121
|
+
# => "<br />"
|
120
122
|
|
121
|
-
|
122
|
-
|
123
|
+
span "something"
|
124
|
+
# => "<span>something</span>"
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
+
div "something", :style => "color: red"
|
127
|
+
# => "<div style=\"color: red\">somthing</div"
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
}
|
132
|
-
} # => "<html><head><title>Hello World</title></head><body<h1>Hi There!</h1></body></html>"
|
129
|
+
html(
|
130
|
+
head(title("Hello World")),
|
131
|
+
body(h1("Hi There!"))
|
132
|
+
) # => "<html><head><title>Hello World</title></head><body<h1>Hi There!</h1></body></html>"
|
133
133
|
```
|
134
134
|
|
135
|
-
You can't
|
135
|
+
You can't specify content blocks when capturing element output. Any content blocks will be ignored.
|
136
136
|
|
137
137
|
```ruby
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
138
|
+
div("contents") {
|
139
|
+
span "more content"
|
140
|
+
}
|
141
|
+
# => "<div>contents</div>"
|
142
142
|
```
|
143
143
|
|
144
144
|
Use bang (!) method calls to set id attributes
|
145
145
|
|
146
146
|
```ruby
|
147
|
-
|
148
|
-
|
147
|
+
h1.header!
|
148
|
+
# => "<h1 id=\"header\" />"
|
149
149
|
|
150
|
-
|
151
|
-
|
150
|
+
h1.header!.title!
|
151
|
+
# => "<h1 id=\"title\" />"
|
152
152
|
```
|
153
153
|
|
154
154
|
Use general method calls to add class attributes
|
155
155
|
|
156
156
|
```ruby
|
157
|
-
|
158
|
-
|
157
|
+
_h1.header.awesome
|
158
|
+
# => "<h1 class=\"header awesome\" />"
|
159
159
|
```
|
160
160
|
|
161
161
|
Use both in combination
|
162
162
|
|
163
163
|
```ruby
|
164
|
-
|
165
|
-
|
164
|
+
h1.header!.awesome
|
165
|
+
# => "<h1 class=\"awesome\" id=\"header\" />
|
166
166
|
```
|
167
167
|
|
168
168
|
## Streamed Output
|
@@ -179,19 +179,19 @@ Stream plain text
|
|
179
179
|
*note*: this is only valid at the root of the view. to add plain text to an element, pass it in as an argument. it will get streamed out as the element is streamed.
|
180
180
|
|
181
181
|
```ruby
|
182
|
-
|
182
|
+
_ "this will be escaped"
|
183
183
|
|
184
|
-
|
185
|
-
|
184
|
+
_ raw("this will not be escaped")
|
185
|
+
```
|
186
186
|
|
187
187
|
### XML
|
188
188
|
|
189
189
|
Stream xml element markup. Call the element and tag methods with two leading underscores.
|
190
190
|
|
191
191
|
```ruby
|
192
|
-
|
192
|
+
__element(:thing)
|
193
193
|
|
194
|
-
|
194
|
+
__tag('ns:thing')
|
195
195
|
```
|
196
196
|
|
197
197
|
All other element handling is the same.
|
@@ -201,18 +201,18 @@ All other element handling is the same.
|
|
201
201
|
Stream html markup. Call the html element methods with a leading underscore.
|
202
202
|
|
203
203
|
```ruby
|
204
|
-
|
204
|
+
_br
|
205
205
|
|
206
|
-
|
206
|
+
_span "something"
|
207
207
|
|
208
|
-
|
208
|
+
_div "something", :style => "color: red"
|
209
209
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
210
|
+
_html {
|
211
|
+
_head { _title "Hello World" }
|
212
|
+
_body {
|
213
|
+
_h1 "Hi There!"
|
214
|
+
}
|
215
|
+
}
|
216
216
|
```
|
217
217
|
|
218
218
|
All other element handling is the same.
|
@@ -230,11 +230,13 @@ All other element handling is the same.
|
|
230
230
|
|
231
231
|
To render using Undies, create a Template instance, providing the template source, data, and io information.
|
232
232
|
|
233
|
-
|
234
|
-
|
235
|
-
|
233
|
+
```ruby
|
234
|
+
source = Undies::Source.new("/path/to/sourcefile")
|
235
|
+
data = { :two_plus_two => 4 }
|
236
|
+
io = Undies::IO.new(@some_io_stream)
|
236
237
|
|
237
|
-
|
238
|
+
Undies::Template.new(source, data, io)
|
239
|
+
```
|
238
240
|
|
239
241
|
### Source
|
240
242
|
|
@@ -256,26 +258,26 @@ As said before, Undies streams to a given io stream. You specify a Template's i
|
|
256
258
|
file source, no local data, no pretty printing
|
257
259
|
|
258
260
|
```ruby
|
259
|
-
|
260
|
-
|
261
|
+
source = Undies::Source.new("/path/to/source")
|
262
|
+
Undies::Template.new(source, {}, Undies::IO.new(@io))
|
261
263
|
```
|
262
264
|
|
263
265
|
proc source, simple local data, no pretty printing
|
264
266
|
|
265
267
|
```ruby
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
268
|
+
source = Undies::Source.new(Proc.new do
|
269
|
+
_div {
|
270
|
+
_ @content.to_s
|
271
|
+
}
|
272
|
+
end)
|
273
|
+
Undies::Template.new(source, {:content => "Some Content!!" }, Undies::IO.new(@io))
|
272
274
|
```
|
273
275
|
|
274
276
|
pretty printing (4 space tab indentation)
|
275
277
|
|
276
278
|
```ruby
|
277
|
-
|
278
|
-
|
279
|
+
source = Undies::Source.new("/path/to/source")
|
280
|
+
Undies::Template.new(source, {}, Undies::IO.new(@io, :pp => 4))
|
279
281
|
```
|
280
282
|
|
281
283
|
### Builder approach
|
@@ -285,28 +287,28 @@ The above examples use the "source rendering" approach. This works great when y
|
|
285
287
|
To render using this approach, create a Template instance passing it data and io info as above. However, don't pass in any source info, only pass in any local data if you like, and save off the created template:
|
286
288
|
|
287
289
|
```ruby
|
288
|
-
|
289
|
-
|
290
|
+
# choosing not to use any local data in this example
|
291
|
+
template = Undies::Template.new(Undies::IO.new(@io))
|
290
292
|
```
|
291
293
|
|
292
294
|
Now just interact with the Undies API directly.
|
293
295
|
|
294
296
|
```ruby
|
295
|
-
|
296
|
-
|
297
|
-
|
297
|
+
# notice that it becomes less important to bind any local data to the Template using this approach
|
298
|
+
something = "Some Thing!"
|
299
|
+
template._div.something! template._ something.to_s
|
298
300
|
|
299
|
-
|
300
|
-
|
301
|
-
|
301
|
+
template._div {
|
302
|
+
template._span "hi"
|
303
|
+
}
|
302
304
|
```
|
303
305
|
|
304
306
|
*Note:* there is one extra caveat to be aware of using this approach. You need to be sure and flush the template when content processing is complete. Just pass the template to the Undies::Template#flush method:
|
305
307
|
|
306
308
|
```ruby
|
307
|
-
|
308
|
-
|
309
|
-
|
309
|
+
# ensures all content is streamed to the template's io stream
|
310
|
+
# this is necessary when not using the source approach above
|
311
|
+
Undies::Template.flush(template)
|
310
312
|
```
|
311
313
|
|
312
314
|
### Manual approach
|
@@ -316,20 +318,20 @@ There is another method you can use to render output: the manual approach. Like
|
|
316
318
|
To render using this approach, create a Template as you would with the Builder approach. Interact with the Undies API directly. Use the Template#__push and Template#__pop methods to change the template scope.
|
317
319
|
|
318
320
|
```ruby
|
319
|
-
|
321
|
+
# this is the equivalent to the Builder approach example above
|
320
322
|
|
321
|
-
|
323
|
+
template = Undies::Template.new(Undies::IO.new(@io))
|
322
324
|
|
323
|
-
|
324
|
-
|
325
|
+
something = "Some Thing!"
|
326
|
+
template._div.something! something.to_s
|
325
327
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
328
|
+
template._div
|
329
|
+
template.__push
|
330
|
+
template._span "hi"
|
331
|
+
template.__pop
|
330
332
|
|
331
|
-
|
332
|
-
|
333
|
+
# alternate method for flushing a template
|
334
|
+
template.__flush
|
333
335
|
```
|
334
336
|
|
335
337
|
*Note:* as with the Builder approach, you must flush the template when content processing is complete.
|
data/Rakefile
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
require
|
2
|
-
Assert::RakeTasks.for(:test)
|
3
|
-
|
4
|
-
require 'bundler'
|
5
|
-
Bundler::GemHelper.install_tasks
|
6
|
-
|
7
|
-
task :default => :build
|
1
|
+
require "bundler/gem_tasks"
|
8
2
|
|
9
3
|
namespace :bench do
|
10
4
|
|
@@ -34,4 +28,3 @@ end
|
|
34
28
|
task :bench do
|
35
29
|
Rake::Task['bench:run'].invoke
|
36
30
|
end
|
37
|
-
|
data/lib/undies/api.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'undies/element_node'
|
2
2
|
require 'undies/element'
|
3
|
+
require 'undies/raw'
|
3
4
|
|
4
5
|
module Undies
|
5
6
|
|
@@ -71,7 +72,7 @@ module Undies
|
|
71
72
|
|
72
73
|
# streaming methods
|
73
74
|
|
74
|
-
# Add a text node (data escaped) to the
|
75
|
+
# Add a text node (data escaped) to the current node
|
75
76
|
def _(data="")
|
76
77
|
@_undies_io.current.text(self.class.escape_html(data.to_s))
|
77
78
|
end
|
data/lib/undies/element.rb
CHANGED
@@ -1,49 +1,46 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
ESCAPE_ATTRS = {
|
24
|
-
"&" => "&",
|
25
|
-
"<" => "<",
|
26
|
-
'"' => """
|
27
|
-
}
|
28
|
-
ESCAPE_ATTRS_PATTERN = Regexp.union(*ESCAPE_ATTRS.keys)
|
29
|
-
def self.escape_attr_value(value)
|
30
|
-
value.to_s.gsub(ESCAPE_ATTRS_PATTERN){|c| ESCAPE_ATTRS[c] }
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.open(*args, &build)
|
34
|
-
Open.new(*args, &build)
|
35
|
-
end
|
1
|
+
require 'undies/raw'
|
2
|
+
require 'undies/template'
|
3
|
+
|
4
|
+
module Undies; end
|
5
|
+
module Undies::Element
|
6
|
+
|
7
|
+
def self.hash_attrs(attrs="", ns=nil)
|
8
|
+
return attrs.to_s if !attrs.kind_of?(::Hash)
|
9
|
+
|
10
|
+
attrs.collect do |k_v|
|
11
|
+
[ns ? "#{ns}_#{k_v.first}" : k_v.first.to_s, k_v.last]
|
12
|
+
end.sort.collect do |k_v|
|
13
|
+
if k_v.last.kind_of?(::Hash)
|
14
|
+
hash_attrs(k_v.last, k_v.first)
|
15
|
+
elsif k_v.last.kind_of?(::Array)
|
16
|
+
" #{k_v.first}=\"#{escape_attr_value(k_v.last.join(' '))}\""
|
17
|
+
else
|
18
|
+
" #{k_v.first}=\"#{escape_attr_value(k_v.last)}\""
|
19
|
+
end
|
20
|
+
end.join
|
21
|
+
end
|
36
22
|
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
ESCAPE_ATTRS = {
|
24
|
+
"&" => "&",
|
25
|
+
"<" => "<",
|
26
|
+
'"' => """
|
27
|
+
}
|
28
|
+
ESCAPE_ATTRS_PATTERN = Regexp.union(*ESCAPE_ATTRS.keys)
|
29
|
+
def self.escape_attr_value(value)
|
30
|
+
value.to_s.gsub(ESCAPE_ATTRS_PATTERN){|c| ESCAPE_ATTRS[c] }
|
31
|
+
end
|
40
32
|
|
33
|
+
def self.open(*args, &build)
|
34
|
+
Open.new(*args, &build)
|
41
35
|
end
|
42
36
|
|
37
|
+
def self.closed(*args, &build)
|
38
|
+
Closed.new(*args, &build)
|
39
|
+
end
|
43
40
|
|
41
|
+
## Utility Classes
|
44
42
|
|
45
43
|
module CSSProxy
|
46
|
-
|
47
44
|
ID_METH_REGEX = /^([^_].+)!$/
|
48
45
|
CLASS_METH_REGEX = /^([^_].+)$/
|
49
46
|
|
@@ -66,45 +63,16 @@ module Undies
|
|
66
63
|
super
|
67
64
|
end
|
68
65
|
end
|
69
|
-
|
70
66
|
end
|
71
67
|
|
72
|
-
|
73
|
-
|
74
68
|
module MergeAttrs
|
75
|
-
|
76
69
|
def __attrs(attrs_hash=nil)
|
77
70
|
return @attrs if attrs_hash.nil?
|
78
71
|
@attrs.merge!(attrs_hash)
|
79
72
|
end
|
80
|
-
|
81
73
|
end
|
82
74
|
|
83
|
-
|
84
|
-
|
85
|
-
class Raw < ::String
|
86
|
-
|
87
|
-
# A Raw string is one that is impervious to String#gsub
|
88
|
-
# and returns itself when `to_s` is called. Used to circumvent
|
89
|
-
# the default html escaping of markup
|
90
|
-
|
91
|
-
def gsub(*args)
|
92
|
-
self
|
93
|
-
end
|
94
|
-
|
95
|
-
def gsub!(*args)
|
96
|
-
nil
|
97
|
-
end
|
98
|
-
|
99
|
-
def to_s
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
class Element::Open
|
75
|
+
class Open
|
108
76
|
include CSSProxy
|
109
77
|
include MergeAttrs
|
110
78
|
|
@@ -118,11 +86,11 @@ module Undies
|
|
118
86
|
end
|
119
87
|
|
120
88
|
def __start_tag
|
121
|
-
"<#{@name}#{Element.hash_attrs(@attrs)}>"
|
89
|
+
"<#{@name}#{Undies::Element.hash_attrs(@attrs)}>"
|
122
90
|
end
|
123
91
|
|
124
92
|
def __content
|
125
|
-
@content.collect{ |c| Template.escape_html(c) }.join
|
93
|
+
@content.collect{ |c| Undies::Template.escape_html(c) }.join
|
126
94
|
end
|
127
95
|
|
128
96
|
def __build
|
@@ -134,7 +102,7 @@ module Undies
|
|
134
102
|
end
|
135
103
|
|
136
104
|
def to_s
|
137
|
-
Raw.new("#{__start_tag}#{__content}#{__end_tag}")
|
105
|
+
Undies::Raw.new("#{__start_tag}#{__content}#{__end_tag}")
|
138
106
|
end
|
139
107
|
|
140
108
|
def ==(other)
|
@@ -163,12 +131,9 @@ module Undies
|
|
163
131
|
|
164
132
|
self
|
165
133
|
end
|
166
|
-
|
167
134
|
end
|
168
135
|
|
169
|
-
|
170
|
-
|
171
|
-
class Element::Closed
|
136
|
+
class Closed
|
172
137
|
include CSSProxy
|
173
138
|
include MergeAttrs
|
174
139
|
|
@@ -179,7 +144,7 @@ module Undies
|
|
179
144
|
end
|
180
145
|
|
181
146
|
def __start_tag
|
182
|
-
"<#{@name}#{Element.hash_attrs(@attrs)} />"
|
147
|
+
"<#{@name}#{Undies::Element.hash_attrs(@attrs)} />"
|
183
148
|
end
|
184
149
|
|
185
150
|
# closed elements have no content
|
@@ -192,7 +157,7 @@ module Undies
|
|
192
157
|
def __end_tag; ''; end
|
193
158
|
|
194
159
|
def to_s
|
195
|
-
Raw.new("#{__start_tag}")
|
160
|
+
Undies::Raw.new("#{__start_tag}")
|
196
161
|
end
|
197
162
|
|
198
163
|
def ==(other)
|
@@ -214,9 +179,6 @@ module Undies
|
|
214
179
|
@attrs.merge!(args.last || {})
|
215
180
|
self
|
216
181
|
end
|
217
|
-
|
218
182
|
end
|
219
183
|
|
220
|
-
|
221
|
-
|
222
184
|
end
|
data/lib/undies/element_node.rb
CHANGED
@@ -4,11 +4,11 @@ module Undies
|
|
4
4
|
|
5
5
|
class ElementNode
|
6
6
|
|
7
|
-
#
|
8
|
-
# processes nested markup and elements. At each node level
|
9
|
-
# tree, nodes/markup are cached until the next sibling node or
|
10
|
-
# is defined, or until the node is flushed. This keeps nodes from
|
11
|
-
# memory on large documents and allows for output streaming.
|
7
|
+
# ElemmentNode is used internally to implement the markup tree nodes. Each
|
8
|
+
# node caches and processes nested markup and elements. At each node level
|
9
|
+
# in the markup tree, nodes/markup are cached until the next sibling node or
|
10
|
+
# raw markup is defined, or until the node is flushed. This keeps nodes from
|
11
|
+
# bloating memory on large documents and allows for output streaming.
|
12
12
|
|
13
13
|
# ElementNode is specifically used to handle nested element markup.
|
14
14
|
|
@@ -113,4 +113,5 @@ module Undies
|
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
116
|
+
|
116
117
|
end
|