ahoward-tagz 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/samples/a.rb ADDED
@@ -0,0 +1,15 @@
1
+ #
2
+ # in the simplest case tagz generates html using a syntax which safely mixes
3
+ # in to any object
4
+ #
5
+
6
+ require 'tagz'
7
+ include Tagz.globally
8
+
9
+ class GiraffeModel
10
+ def link
11
+ a_(:href => "/giraffe/neck/42"){ "whack!" }
12
+ end
13
+ end
14
+
15
+ puts GiraffeModel.new.link
data/samples/b.rb ADDED
@@ -0,0 +1,36 @@
1
+ #
2
+ # tagz.rb mixes quite easily with your favourite templating engine, avoiding
3
+ # the need for '<% rows.each do |row| %> ... <% row.each do |cell| %> '
4
+ # madness and other types of logic to be coded in the templating language,
5
+ # leaving templating to template engines and logic and looping to ruby -
6
+ # unencumbered by extra funky syntax. in rails tagz will automatically be
7
+ # available in your erb templates.
8
+ #
9
+
10
+ require 'tagz'
11
+ include Tagz.globally
12
+
13
+ require 'erb'
14
+
15
+ rows = %w( a b c ), %w( 1 2 3 )
16
+
17
+ template = ERB.new <<-ERB
18
+ <html>
19
+ <body>
20
+ <%=
21
+ table_{
22
+ rows.each do |row|
23
+ tr_{
24
+ row.each do |cell|
25
+ td_{ cell }
26
+ end
27
+ }
28
+ end
29
+ }
30
+ %>
31
+ </body>
32
+ </html>
33
+ ERB
34
+
35
+ puts template.result(binding)
36
+
data/samples/c.rb ADDED
@@ -0,0 +1,15 @@
1
+ #
2
+ # once you've learned to generate html using tagz you're primed to generate
3
+ # xml too
4
+ #
5
+
6
+ require 'tagz'
7
+ include Tagz.globally
8
+
9
+ doc =
10
+ xml_{
11
+ giraffe_{ 'large' }
12
+ ninja_{ 'small' }
13
+ }
14
+
15
+ puts doc
data/samples/d.rb ADDED
@@ -0,0 +1,28 @@
1
+ #
2
+ # tagz.rb doesn't cramp your style, allowing even invalid html to be
3
+ # generated. note the use of the 'tagz' method, which can be used both to
4
+ # capture output and to append content to the top of the stack.
5
+ #
6
+
7
+ require 'tagz'
8
+ include Tagz.globally
9
+
10
+ def header
11
+ tagz{
12
+ html_
13
+ body_(:class => 'ninja-like', :id => 'giraffe-slayer')
14
+
15
+ __ "<!-- this is the header -->"
16
+ }
17
+ end
18
+
19
+ def footer
20
+ tagz{
21
+ __ "<!-- this is the footer -->"
22
+
23
+ _body
24
+ _html
25
+ }
26
+ end
27
+
28
+ puts header, footer
data/samples/e.rb ADDED
@@ -0,0 +1,21 @@
1
+ #
2
+ # tagz.rb allows a safer method of mixin which requires any tagz methods to be
3
+ # insider a tagz block - tagz generating methods outside a tagz block with
4
+ # raise an error if tagz is included this way. also notice that the error is
5
+ # reported from where it was raised - not from the bowels of the the tagz.rb
6
+ # lib.
7
+ #
8
+
9
+ require 'tagz'
10
+ include Tagz
11
+
12
+ puts tagz{
13
+ html_{ 'works only in here' }
14
+ }
15
+
16
+ begin
17
+ html_{ 'not out here' }
18
+ rescue Object => e
19
+ p :backtrace => e.backtrace
20
+ end
21
+
data/samples/f.rb ADDED
@@ -0,0 +1,22 @@
1
+ #
2
+ # tagz.rb can generate really compact html. this is great to save bandwidth
3
+ # but can sometimes make reading the generated html a bit rough. of course
4
+ # using tidy or the dom inspector in firebug obviates the issue; nevertheless
5
+ # it's sometime nice to break things up a little. you can use 'tagz << "\n"'
6
+ # or the special shorthand '__' or '___' to accomplish this
7
+ #
8
+
9
+ require 'tagz'
10
+ include Tagz.globally
11
+
12
+ html =
13
+ div_{
14
+ span_{ true }
15
+ __
16
+ span_{ false } # hey ryan, i fixed this ;-)
17
+ ___
18
+
19
+ ___ 'foo & escaped bar'
20
+ }
21
+
22
+ puts html
data/samples/g.rb ADDED
@@ -0,0 +1,19 @@
1
+ # tagz gives you low-level control of the output and makes even dashersized
2
+ # xml tagz easy enough to work with
3
+ #
4
+
5
+ require 'tagz'
6
+ include Tagz.globally
7
+
8
+ xml =
9
+ root_{
10
+ tagz__('foo-bar', :key => 'foo&bar'){ 'content' }
11
+
12
+ tagz__('bar-foo')
13
+ tagz.concat 'content'
14
+ tagz.concat tagz.escape('foo&bar')
15
+ __tagz('bar-foo')
16
+ }
17
+
18
+ puts xml
19
+
data/tagz-5.1.0.gem ADDED
Binary file
data/tagz.gemspec ADDED
@@ -0,0 +1,25 @@
1
+
2
+ Gem::Specification::new do |spec|
3
+ spec.name = "tagz"
4
+ spec.version = "5.1.0"
5
+ spec.platform = Gem::Platform::RUBY
6
+ spec.summary = "tagz"
7
+
8
+ spec.files = ["gen_readme.rb", "install.rb", "lib", "lib/tagz.rb", "README", "README.tmpl", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb", "samples/g.rb", "tagz-5.1.0.gem", "tagz.gemspec", "test", "test/tagz.rb"]
9
+ spec.executables = []
10
+
11
+ spec.require_path = "lib"
12
+
13
+ spec.has_rdoc = true
14
+ spec.test_files = "test/tagz.rb"
15
+ #spec.add_dependency 'lib', '>= version'
16
+ #spec.add_dependency 'fattr'
17
+
18
+ spec.extensions.push(*[])
19
+
20
+ spec.rubyforge_project = 'codeforpeople'
21
+ spec.author = "Ara T. Howard"
22
+ spec.email = "ara.t.howard@gmail.com"
23
+ spec.homepage = "http://github.com/ahoward/tagz/tree/master"
24
+ end
25
+
data/test/tagz.rb ADDED
@@ -0,0 +1,671 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+
5
+ $VERBOSE = 2
6
+ STDOUT.sync = true
7
+ $:.unshift 'lib'
8
+ $:.unshift '../lib'
9
+ $:.unshift '.'
10
+
11
+ require 'tagz'
12
+
13
+ class TagzTest < Test::Unit::TestCase
14
+ include Tagz
15
+
16
+ class ::String
17
+ Equal = instance_method '=='
18
+ remove_method '=='
19
+ def == other
20
+ Equal.bind(self.delete(' ')).call other.to_s.delete(' ')
21
+ end
22
+ end
23
+
24
+ def test_000
25
+ expected = '<foo ></foo>'
26
+ actual = tagz{
27
+ foo_
28
+ _foo
29
+ }
30
+ assert_equal expected, actual
31
+ end
32
+
33
+ def test_010
34
+ expected = '<foo ><bar ></bar></foo>'
35
+ actual = tagz{
36
+ foo_
37
+ bar_
38
+ _bar
39
+ _foo
40
+ }
41
+ assert_equal expected, actual
42
+ end
43
+
44
+ def test_020
45
+ expected = '<foo ><bar /></foo>'
46
+ actual = tagz{
47
+ foo_
48
+ bar_{}
49
+ _foo
50
+ }
51
+ assert_equal expected, actual
52
+ end
53
+
54
+ def test_030
55
+ expected = '<foo ><bar /></foo>'
56
+ actual = tagz{
57
+ foo_{
58
+ bar_{}
59
+ }
60
+ }
61
+ assert_equal expected, actual
62
+ end
63
+
64
+ def test_040
65
+ expected = '<foo >bar</foo>'
66
+ actual = tagz{
67
+ foo_{ 'bar' }
68
+ }
69
+ assert_equal expected, actual
70
+ end
71
+
72
+ def test_050
73
+ expected = '<foo ><bar >foobar</bar></foo>'
74
+ actual = tagz{
75
+ foo_{
76
+ bar_{ 'foobar' }
77
+ }
78
+ }
79
+ assert_equal expected, actual
80
+ end
81
+
82
+ def test_060
83
+ expected = '<foo key="value" ><bar a="b" >foobar</bar></foo>'
84
+ actual = tagz{
85
+ foo_('key' => 'value'){
86
+ bar_(:a => :b){ 'foobar' }
87
+ }
88
+ }
89
+ assert_equal expected, actual
90
+ end
91
+
92
+ def test_070
93
+ expected = '<foo /><bar />'
94
+ actual = tagz{
95
+ foo_{} + bar_{}
96
+ }
97
+ assert_equal expected, actual
98
+ end
99
+
100
+ =begin
101
+ def test_080
102
+ assert_raises(Tagz::NotOpen) do
103
+ foo_{ _bar }
104
+ end
105
+ end
106
+ def test_090
107
+ assert_raises(Tagz::NotOpen) do
108
+ _foo
109
+ end
110
+ end
111
+ def test_100
112
+ assert_nothing_raised do
113
+ foo_
114
+ _foo
115
+ end
116
+ end
117
+ =end
118
+
119
+ def test_110
120
+ expected = '<foo ><bar >foobar</bar></foo>'
121
+ actual = tagz{
122
+ foo_{
123
+ bar_{ 'foobar' }
124
+ 'this content is ignored because the block added content'
125
+ }
126
+ }
127
+ assert_equal expected, actual
128
+ end
129
+
130
+ def test_120
131
+ expected = '<foo ><bar >foobar</bar><baz >barfoo</baz></foo>'
132
+ actual = tagz{
133
+ foo_{
134
+ bar_{ 'foobar' }
135
+ baz_{ 'barfoo' }
136
+ }
137
+ }
138
+ assert_equal expected, actual
139
+ end
140
+
141
+ def test_121
142
+ expected = '<foo ><bar >foobar</bar><baz >barfoo</baz></foo>'
143
+ actual = tagz{
144
+ foo_{
145
+ bar_{ 'foobar' }
146
+ baz_{ 'barfoo' }
147
+ }
148
+ }
149
+ assert_equal expected, actual
150
+ end
151
+
152
+ def test_130
153
+ expected = '<foo >a<bar >foobar</bar>b<baz >barfoo</baz></foo>'
154
+ actual = tagz{
155
+ foo_{ |t|
156
+ t << 'a'
157
+ bar_{ 'foobar' }
158
+ t << 'b'
159
+ baz_{ 'barfoo' }
160
+ }
161
+ }
162
+ assert_equal expected, actual
163
+ end
164
+
165
+ def test_140
166
+ expected = '<foo ><bar >baz</bar></foo>'
167
+ actual = tagz{
168
+ foo_{
169
+ bar_ << 'baz'
170
+ _bar
171
+ }
172
+ }
173
+ assert_equal expected, actual
174
+ end
175
+
176
+ def test_150
177
+ expected = '<foo ><bar >bar<baz >baz</baz></bar></foo>'
178
+ actual = tagz{
179
+ foo_{
180
+ bar_ << 'bar'
181
+ tag = baz_
182
+ tag << 'baz'
183
+ _baz
184
+ _bar
185
+ }
186
+ }
187
+ assert_equal expected, actual
188
+ end
189
+
190
+ def test_160
191
+ expected = '<foo >a<bar >b</bar></foo>'
192
+ actual = tagz{
193
+ foo_{ |foo|
194
+ foo << 'a'
195
+ bar_{ |bar|
196
+ bar << 'b'
197
+ }
198
+ }
199
+ }
200
+ assert_equal expected, actual
201
+ end
202
+
203
+ def test_170
204
+ expected = '<html ><body ><ul ><li >a</li><li >b</li><li >c</li></ul></body></html>'
205
+ @list = %w( a b c )
206
+ actual = tagz{
207
+ html_{
208
+ body_{
209
+ ul_{
210
+ @list.each{|elem| li_{ elem } }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ assert_equal expected, actual
216
+ end
217
+
218
+ def test_180
219
+ expected = '<html ><body >42</body></html>'
220
+ actual = tagz{
221
+ html_{
222
+ b = body_
223
+ b << 42
224
+ _body
225
+ }
226
+ }
227
+ assert_equal expected, actual
228
+ end
229
+
230
+ def test_190
231
+ expected = '<html ><body >42</body></html>'
232
+ actual = tagz{
233
+ html_{
234
+ body_
235
+ tagz << 42 ### tagz is always the current tag!
236
+ _body
237
+ }
238
+ }
239
+ assert_equal expected, actual
240
+ end
241
+
242
+ def test_200
243
+ expected = '<html ><body >42</body></html>'
244
+ actual = tagz{
245
+ html_{
246
+ body_{
247
+ tagz << 42 ### tagz is always the current tag!
248
+ }
249
+ }
250
+ }
251
+ assert_equal expected, actual
252
+ end
253
+
254
+ def test_210
255
+ expected = '<html ><body >42</body></html>'
256
+ actual = tagz{
257
+ html_{
258
+ body_{ |body|
259
+ body << 42
260
+ }
261
+ }
262
+ }
263
+ assert_equal expected, actual
264
+ end
265
+
266
+ =begin
267
+ def test_220
268
+ expected = '<html ><body >42</body></html>'
269
+ actual = tagz{
270
+ 'html'.tag do
271
+ 'body'.tag do
272
+ 42
273
+ end
274
+ end
275
+ }
276
+ assert_equal expected, actual
277
+ end
278
+ =end
279
+
280
+ def test_230
281
+ expected = '<html ><body ><div k="v" >content</div></body></html>'
282
+ actual = tagz{
283
+ html_{
284
+ body_{
285
+ div_(:k => :v){ "content" }
286
+ }
287
+ }
288
+ }
289
+ assert_equal expected, actual
290
+ end
291
+
292
+ def test_240
293
+ expected = '<html ><body ><div k="v" >content</div></body></html>'
294
+ actual = tagz{
295
+ html_{
296
+ body_{
297
+ div_ "content", :k => :v
298
+ }
299
+ }
300
+ }
301
+ assert_equal expected, actual
302
+ end
303
+
304
+ def test_241
305
+ expected = '<html ><body ><div k="v" >content</div></div></body></html>'
306
+ actual = tagz{
307
+ html_{
308
+ body_{
309
+ div_ "content", :k => :v
310
+ _div
311
+ }
312
+ }
313
+ }
314
+ assert_equal expected, actual
315
+ end
316
+
317
+ def test_250
318
+ expected = '<html ><body ><div k="v" >content and more content</div></body></html>'
319
+ actual = tagz{
320
+ html_{
321
+ body_{
322
+ div_("content", :k => :v){ ' and more content' }
323
+ }
324
+ }
325
+ }
326
+ assert_equal expected, actual
327
+ end
328
+
329
+ def test_260
330
+ expected = '<html ><body ><div k="v" >content</div></body></html>'
331
+ actual = tagz{
332
+ html_{
333
+ body_{
334
+ div_ :k => :v
335
+ tagz << "content"
336
+ _div
337
+ }
338
+ }
339
+ }
340
+ assert_equal expected, actual
341
+ end
342
+
343
+ def test_270
344
+ expected = '<html ><body ><div k="v" >content</div></body></html>'
345
+ actual = tagz{
346
+ html_{
347
+ body_{
348
+ div_ :k => :v
349
+ tagz << "content"
350
+ _div
351
+ }
352
+ }
353
+ }
354
+ assert_equal expected, actual
355
+ end
356
+
357
+ def test_280
358
+ expected = 'content'
359
+ actual = tagz{
360
+ tagz << "content"
361
+ }
362
+ assert_equal expected, actual
363
+ end
364
+
365
+ def test_290
366
+ expected = 'foobar'
367
+ actual = tagz{
368
+ tagz {
369
+ tagz << 'foo' << 'bar'
370
+ }
371
+ }
372
+ assert_equal expected, actual
373
+ end
374
+
375
+ =begin
376
+ def test_300
377
+ expected = 'foobar'
378
+ actual = tagz{
379
+ tagz{ tagz 'foo', 'bar' }
380
+ }
381
+ assert_equal expected, actual
382
+ end
383
+ =end
384
+
385
+ def test_310
386
+ expected = '<html ><body ><div k="v" >foobar</div></body></html>'
387
+ actual = tagz{
388
+ html_{
389
+ body_{
390
+ div_! "foo", "bar", :k => :v
391
+ }
392
+ }
393
+ }
394
+ assert_equal expected, actual
395
+ end
396
+
397
+ def test_320
398
+ expected = '<html ><body ><a href="a" >a</a><span >|</span><a href="b" >b</a><span >|</span><a href="c" >c</a></body></html>'
399
+ links = %w( a b c )
400
+ actual = tagz{
401
+ html_{
402
+ body_{
403
+ tagz.write links.map{|link| e(:a, :href => link){ link }}.join(e(:span){ '|' })
404
+ }
405
+ }
406
+ }
407
+ assert_equal expected, actual
408
+ end
409
+
410
+ def test_330
411
+ expected = '<a ><b ><c >'
412
+ actual = tagz{
413
+ tagz {
414
+ a_
415
+ b_
416
+ c_
417
+ }
418
+ }
419
+ assert_equal expected, actual
420
+ end
421
+
422
+ def test_340
423
+ expected = '<a ><b ><c ></a>'
424
+ actual = tagz{
425
+ a_ {
426
+ b_
427
+ c_
428
+ }
429
+ }
430
+ assert_equal expected, actual
431
+ end
432
+
433
+ def test_350
434
+ expected = '<a ><b ><c >content</c></a>'
435
+ actual = tagz{
436
+ a_ {
437
+ b_
438
+ c_ "content"
439
+ }
440
+ }
441
+ assert_equal expected, actual
442
+ end
443
+
444
+ def test_360
445
+ expected = '<a ><b >content</b><c ><d >more content</d></a>'
446
+ actual = tagz{
447
+ a_ {
448
+ b_ "content"
449
+ c_
450
+ d_ "more content"
451
+ }
452
+ }
453
+ assert_equal expected, actual
454
+ end
455
+
456
+ =begin
457
+ def test_370
458
+ expected = 'ab'
459
+ actual = tagz{
460
+ re = 'a'
461
+ re << tagz{'b'}
462
+ re
463
+ }
464
+ assert_equal expected, actual
465
+ end
466
+ =end
467
+
468
+ def test_380
469
+ expected = 'ab'
470
+ actual = tagz{
471
+ tagz{ 'a' } + tagz{ 'b' }
472
+ }
473
+ assert_equal expected, actual
474
+ end
475
+
476
+ def test_390
477
+ expected = '<div class="bar&amp;foo&gt;">foo&amp;bar&gt;</div>'
478
+ # actual = tagz{ div_(:class => 'bar&foo>'){|t| t.h('foo&bar>') } }
479
+ actual = tagz{ div_(:class => 'bar&foo>'){ 'foo&bar>' } }
480
+ assert_equal expected, actual
481
+
482
+ expected = %|<div class="bar&amp;foo&gt;">#{ expected }</div>|
483
+ actual = tagz{ div_(:class => 'bar&foo>'){ actual } }
484
+ assert_equal expected, actual
485
+ end
486
+
487
+ def test_400
488
+ expected = '<div><span>foo&amp;bar</span></div>'
489
+ actual = tagz{ div_{ span_{ 'foo&bar' } } }
490
+ assert_equal expected, actual
491
+ end
492
+
493
+ def test_410
494
+ expected = '<div>false</div>'
495
+ actual = tagz{ div_{ false } }
496
+ assert_equal expected, actual
497
+ end
498
+
499
+ def test_420
500
+ expected = "<div>\n<span>foobar</span>\nfoobar\n</div>"
501
+ actual = tagz{ div_{ __; span_{ :foobar }; ___('foobar'); } }
502
+ assert_equal expected, actual
503
+ end
504
+
505
+ def test_430
506
+ c = Class.new{
507
+ include Tagz.globally
508
+ def foobar() div_{ 'foobar' } end
509
+ }.new
510
+
511
+ actual=nil
512
+ assert_nothing_raised{ actual=c.foobar }
513
+ expected = '<div>foobar</div>'
514
+ assert_equal expected, actual
515
+
516
+ =begin
517
+ e = nil
518
+ assert_raises(NoMethodError){ begin; c.missing; ensure; e=$!; end }
519
+ assert e
520
+ messages = e.backtrace.map{|line| line.split(%r/:/, 3).last}
521
+ assert messages.all?{|message| message !~ /tagz/}
522
+ =end
523
+ end
524
+
525
+ def test_440
526
+ c = Class.new{
527
+ include Tagz
528
+ def foobar() tagz{ div_{ 'foobar' } } end
529
+ def barfoo() div_{ 'barfoo' } end
530
+ }.new
531
+
532
+ actual=nil
533
+ assert_nothing_raised{ actual=c.foobar }
534
+ expected = '<div>foobar</div>'
535
+ assert_equal expected, actual
536
+
537
+ assert_raises(NoMethodError){ c.barfoo }
538
+ end
539
+
540
+ def test_450
541
+ c = Class.new{
542
+ include Tagz.globally
543
+ def a() tagz{ a_{ b(tagz); nil } } end
544
+ def b(doc=nil) tagz(doc){ b_{ 'content' } } end
545
+ }.new
546
+
547
+ actual=nil
548
+ assert_nothing_raised{ actual=c.a }
549
+ expected = '<a><b>content</b></a>'
550
+ assert_equal expected, actual
551
+ assert_nothing_raised{ c.b }
552
+ end
553
+
554
+ def test_460
555
+ c = Class.new{
556
+ include Tagz.globally
557
+ def a
558
+ div_( 'a>b' => 'a>b' ){ 'content' }
559
+ end
560
+ }.new
561
+
562
+ actual = nil
563
+ assert_nothing_raised{ actual=c.a}
564
+ expected = %(<div a&gt;b="a&gt;b">content</div>)
565
+ assert_equal expected, actual
566
+
567
+ original = Tagz.escape_attribute! false
568
+ assert original
569
+ actual = nil
570
+ assert_nothing_raised{ actual=c.a}
571
+ expected = %(<div a>b="a>b">content</div>)
572
+ assert_equal expected, actual
573
+
574
+ Tagz.escape_attribute! original
575
+ actual = nil
576
+ assert_nothing_raised{ actual=c.a}
577
+ expected = %(<div a&gt;b="a&gt;b">content</div>)
578
+ assert_equal expected, actual
579
+
580
+ upcased = Tagz.escape_attribute! lambda{|value| original.call(value).upcase}
581
+ assert upcased
582
+ actual = nil
583
+ assert_nothing_raised{ actual=c.a}
584
+ expected = %(<div A&GT;B="A&GT;B">content</div>)
585
+ assert_equal expected, actual
586
+
587
+ Tagz.escape_attributes! lambda{|value| upcased.call(value).downcase}
588
+ actual = nil
589
+ assert_nothing_raised{ actual=c.a}
590
+ expected = %(<div a&gt;b="a&gt;b">content</div>)
591
+ assert_equal expected, actual
592
+ ensure
593
+ Tagz.escape_attributes!(original)
594
+ end
595
+
596
+ def test_470
597
+ c = Class.new{
598
+ include Tagz.globally
599
+ def a
600
+ div_( ){ 'a>b' }
601
+ end
602
+ }.new
603
+
604
+ actual = nil
605
+ assert_nothing_raised{ actual=c.a}
606
+ expected = %(<div>a&gt;b</div>)
607
+ assert_equal expected, actual
608
+
609
+ original = Tagz.escape_content! false
610
+ assert original
611
+ actual = nil
612
+ assert_nothing_raised{ actual=c.a}
613
+ expected = %(<div>a>b</div>)
614
+ assert_equal expected, actual
615
+
616
+ upcased = Tagz.escape_content! lambda{|value| original.call(value).upcase}
617
+ assert upcased
618
+ actual = nil
619
+ assert_nothing_raised{ actual=c.a}
620
+ expected = %(<div>A&GT;B</div>)
621
+ assert_equal expected, actual
622
+
623
+ Tagz.escape_content! original
624
+ actual = nil
625
+ assert_nothing_raised{ actual=c.a}
626
+ expected = %(<div>a&gt;b</div>)
627
+ assert_equal expected, actual
628
+ ensure
629
+ Tagz.escape_content!(original)
630
+ end
631
+
632
+ def test_480
633
+ c = Class.new{
634
+ include Tagz.globally
635
+ def a
636
+ div_( 'a>b' => '<>'){ 'a>b' }
637
+ end
638
+ }.new
639
+
640
+ Tagz.i_know_what_the_hell_i_am_doing!
641
+ actual = nil
642
+ assert_nothing_raised{ actual=c.a}
643
+ expected = %(<div a>b="<>">a>b</div>)
644
+ assert_equal expected, actual
645
+ ensure
646
+ Tagz.i_do_not_know_what_the_hell_i_am_doing!
647
+ end
648
+
649
+ def test_490
650
+ c = Class.new{
651
+ include Tagz.globally
652
+ def a
653
+ div_{
654
+ __
655
+ tagz.concat 'a>b'
656
+ __
657
+ tagz.write 'c>d'
658
+ __
659
+ tagz << 'e>f'
660
+ __
661
+ tagz.push 'g>h'
662
+ }
663
+ end
664
+ }.new
665
+
666
+ actual = nil
667
+ assert_nothing_raised{ actual=c.a}
668
+ expected = "<div>\na&gt;b\nc>d\ne&gt;f\ng>h</div>"
669
+ assert_equal expected, actual
670
+ end
671
+ end