tagz 5.0.1 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +40 -249
- data/Rakefile +228 -0
- data/lib/tagz.rb +234 -154
- data/readme.erb +154 -0
- data/samples/d.rb +4 -4
- data/tagz.gemspec +26 -0
- data/test/tagz.rb +154 -0
- metadata +6 -8
- data/a.rb +0 -12
- data/gemspec.rb +0 -44
- data/gen_readme.rb +0 -34
- data/install.rb +0 -214
- data/prof.rb +0 -25
data/readme.erb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
NAME
|
2
|
+
|
3
|
+
tagz.rb
|
4
|
+
|
5
|
+
SYNOPSIS
|
6
|
+
|
7
|
+
require Tagz
|
8
|
+
|
9
|
+
include Tagz.globally
|
10
|
+
|
11
|
+
a_(:href => "/foo"){ "bar" } #=> <a href="/foo">bar</a>
|
12
|
+
|
13
|
+
DESCRIPTION
|
14
|
+
|
15
|
+
tagz.rb is generates html, xml, or any sgml variant like a small ninja
|
16
|
+
running across the backs of a herd of giraffes swatting of heads like a
|
17
|
+
mark-up weedwacker. weighing in at less than 300 lines of code tagz.rb adds
|
18
|
+
an html/xml/sgml syntax to ruby that is both unobtrusive, safe, and available
|
19
|
+
globally to objects without the need for any builder or superfluous objects.
|
20
|
+
tagz.rb is designed for applications that generate html to be able to do so
|
21
|
+
easily in any context without heavyweight syntax or scoping issues, like a
|
22
|
+
ninja sword through butter.
|
23
|
+
|
24
|
+
FEATURES
|
25
|
+
|
26
|
+
- use as a library or mixin
|
27
|
+
|
28
|
+
- simple, clean and consistent mark-up that is easy to visually
|
29
|
+
distinguish from other ruby methods
|
30
|
+
|
31
|
+
- auto-compatibility with rails/actionview
|
32
|
+
|
33
|
+
- ability to independently open and close tagz in markup
|
34
|
+
|
35
|
+
- intelligent auto-escaping of both attributes and content for both html
|
36
|
+
and xml
|
37
|
+
|
38
|
+
- validate your html/xml with 'ruby -c' syntax check
|
39
|
+
|
40
|
+
- generally bitchin
|
41
|
+
|
42
|
+
- no lame method_missing approach that prevents tagz like 'type' from being
|
43
|
+
generated
|
44
|
+
|
45
|
+
RAILS
|
46
|
+
|
47
|
+
in config/environment.rb
|
48
|
+
|
49
|
+
require 'tagz'
|
50
|
+
|
51
|
+
in a helper
|
52
|
+
|
53
|
+
def list_of_users
|
54
|
+
ul_(:class => 'users'){
|
55
|
+
@users.each{|user| li_{ user }}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
in a view
|
60
|
+
|
61
|
+
table_{
|
62
|
+
rows.each do |row|
|
63
|
+
tr_{
|
64
|
+
row.each do |cell|
|
65
|
+
td_{ cell }
|
66
|
+
end
|
67
|
+
}
|
68
|
+
end
|
69
|
+
}
|
70
|
+
|
71
|
+
in a controller
|
72
|
+
|
73
|
+
def ajax_responder
|
74
|
+
text =
|
75
|
+
tagz{
|
76
|
+
table_{
|
77
|
+
rows.each do |row|
|
78
|
+
tr_{
|
79
|
+
row.each do |cell|
|
80
|
+
td_{ cell }
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
render :text => text
|
88
|
+
end
|
89
|
+
|
90
|
+
INSTALL
|
91
|
+
|
92
|
+
gem install tagz
|
93
|
+
|
94
|
+
URIS
|
95
|
+
|
96
|
+
http://github.com/ahoward/tagz/tree/master
|
97
|
+
http://rubyforge.org/projects/codeforpeople
|
98
|
+
|
99
|
+
HISTORY
|
100
|
+
6.0.0
|
101
|
+
- reorganize lib to avoid dumping a few constants into the includee - aka
|
102
|
+
don't absolutely minimize namespace pollution. there is now reason to
|
103
|
+
thing this version shouldn't be backwards compat - i bumped the version
|
104
|
+
just in case
|
105
|
+
|
106
|
+
5.1.0
|
107
|
+
- attribute/content auto-escaping can be turned off with
|
108
|
+
|
109
|
+
Tagz.i_know_what_the_hell_i_am_doing!
|
110
|
+
|
111
|
+
and turned back on with
|
112
|
+
|
113
|
+
Tagz.i_do_not_know_what_the_hell_i_am_doing!
|
114
|
+
|
115
|
+
attribute and content escaping can be configured individually too. see
|
116
|
+
tests for examples
|
117
|
+
|
118
|
+
|
119
|
+
thanks Dan Fitzpatrick
|
120
|
+
|
121
|
+
- << and concat escape (if configured) while puts and push and write do not
|
122
|
+
|
123
|
+
thanks JoelVanderWerf
|
124
|
+
|
125
|
+
5.0.0
|
126
|
+
- introduce better escaping for attributes using xchar.rb approach
|
127
|
+
- indroduce smart escaping for content
|
128
|
+
- make Tagz.globally kick ass more hard
|
129
|
+
- note that this version is not backward compatibile if you were relying
|
130
|
+
on tagz never escaping any content should be an ok upgrade for most
|
131
|
+
applications
|
132
|
+
|
133
|
+
4.6.0
|
134
|
+
- fix a bug with self closing tagz that had crept in 1.0.0 -> 4.2.0. thx
|
135
|
+
jeremy hinegardner
|
136
|
+
|
137
|
+
- added tests from 1.0.0 back into svn
|
138
|
+
|
139
|
+
4.4.0
|
140
|
+
- remove dependancy on cgi lib, tagz is now completely standalone
|
141
|
+
|
142
|
+
4.3.0
|
143
|
+
- detect rails and auto-include into ActionController::Base and include
|
144
|
+
globally into ActionView::Base
|
145
|
+
|
146
|
+
4.2.0
|
147
|
+
- general lib cleanup
|
148
|
+
- introduction of dual-mixin technique (Tagz.globally)
|
149
|
+
- few small bug fixes
|
150
|
+
- ninja tales
|
151
|
+
|
152
|
+
SAMPLES
|
153
|
+
|
154
|
+
<%= @samples %>
|
data/samples/d.rb
CHANGED
@@ -12,16 +12,16 @@ def header
|
|
12
12
|
html_
|
13
13
|
body_(:class => 'ninja-like', :id => 'giraffe-slayer')
|
14
14
|
|
15
|
-
|
15
|
+
__ "<!-- this is the header -->"
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
19
|
def footer
|
20
20
|
tagz{
|
21
|
-
|
21
|
+
__ "<!-- this is the footer -->"
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
_body
|
24
|
+
_html
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
data/tagz.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## tagz.gemspec
|
2
|
+
#
|
3
|
+
|
4
|
+
Gem::Specification::new do |spec|
|
5
|
+
spec.name = "tagz"
|
6
|
+
spec.version = "6.0.0"
|
7
|
+
spec.platform = Gem::Platform::RUBY
|
8
|
+
spec.summary = "tagz"
|
9
|
+
|
10
|
+
spec.files = ["lib", "lib/tagz.rb", "Rakefile", "README", "readme.erb", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb", "samples/g.rb", "tagz.gemspec", "test", "test/tagz.rb"]
|
11
|
+
spec.executables = []
|
12
|
+
|
13
|
+
spec.require_path = "lib"
|
14
|
+
|
15
|
+
spec.has_rdoc = true
|
16
|
+
spec.test_files = "test/tagz.rb"
|
17
|
+
#spec.add_dependency 'lib', '>= version'
|
18
|
+
#spec.add_dependency 'fattr'
|
19
|
+
|
20
|
+
spec.extensions.push(*[])
|
21
|
+
|
22
|
+
spec.rubyforge_project = "codeforpeople"
|
23
|
+
spec.author = "Ara T. Howard"
|
24
|
+
spec.email = "ara.t.howard@gmail.com"
|
25
|
+
spec.homepage = "http://github.com/ahoward/tagz/tree/master"
|
26
|
+
end
|
data/test/tagz.rb
CHANGED
@@ -550,4 +550,158 @@ class TagzTest < Test::Unit::TestCase
|
|
550
550
|
assert_equal expected, actual
|
551
551
|
assert_nothing_raised{ c.b }
|
552
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>b="a>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>b="a>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>B="A>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>b="a>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>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>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>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>b\nc>d\ne>f\ng>h</div>"
|
669
|
+
assert_equal expected, actual
|
670
|
+
end
|
671
|
+
|
672
|
+
def test_500
|
673
|
+
expected = actual = nil
|
674
|
+
Module.new do
|
675
|
+
before = constants
|
676
|
+
include Tagz
|
677
|
+
after = constants
|
678
|
+
expected = %w[ TagzConstants ]
|
679
|
+
actual = after - before
|
680
|
+
end
|
681
|
+
assert_equal expected, actual
|
682
|
+
end
|
683
|
+
|
684
|
+
def test_510
|
685
|
+
expected = actual = nil
|
686
|
+
Module.new do
|
687
|
+
before = constants
|
688
|
+
include Tagz.globally
|
689
|
+
after = constants
|
690
|
+
expected = %w[ TagzConstants ]
|
691
|
+
actual = after - before
|
692
|
+
end
|
693
|
+
assert_equal expected, actual
|
694
|
+
end
|
695
|
+
|
696
|
+
def test_520
|
697
|
+
expected = actual = nil
|
698
|
+
Module.new do
|
699
|
+
before = constants
|
700
|
+
include Tagz.privately
|
701
|
+
after = constants
|
702
|
+
expected = %w[ TagzConstants ]
|
703
|
+
actual = after - before
|
704
|
+
end
|
705
|
+
assert_equal expected, actual
|
706
|
+
end
|
553
707
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ara T. Howard
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-25 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,14 +22,11 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- a.rb
|
26
|
-
- gemspec.rb
|
27
|
-
- gen_readme.rb
|
28
|
-
- install.rb
|
29
25
|
- lib
|
30
26
|
- lib/tagz.rb
|
31
|
-
-
|
27
|
+
- Rakefile
|
32
28
|
- README
|
29
|
+
- readme.erb
|
33
30
|
- samples
|
34
31
|
- samples/a.rb
|
35
32
|
- samples/b.rb
|
@@ -38,10 +35,11 @@ files:
|
|
38
35
|
- samples/e.rb
|
39
36
|
- samples/f.rb
|
40
37
|
- samples/g.rb
|
38
|
+
- tagz.gemspec
|
41
39
|
- test
|
42
40
|
- test/tagz.rb
|
43
41
|
has_rdoc: true
|
44
|
-
homepage: http://
|
42
|
+
homepage: http://github.com/ahoward/tagz/tree/master
|
45
43
|
post_install_message:
|
46
44
|
rdoc_options: []
|
47
45
|
|
data/a.rb
DELETED
data/gemspec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
#! /usr/bin/env gem build
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
|
5
|
-
Gem::Specification::new do |spec|
|
6
|
-
$VERBOSE = nil
|
7
|
-
|
8
|
-
shiteless = lambda do |list|
|
9
|
-
list.delete_if do |file|
|
10
|
-
file =~ %r/\.svn/ or
|
11
|
-
file =~ %r/\.tmp/
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
spec.name = $lib
|
16
|
-
spec.version = $version
|
17
|
-
spec.platform = Gem::Platform::RUBY
|
18
|
-
spec.summary = $lib
|
19
|
-
|
20
|
-
spec.files = shiteless[Dir::glob("**/**")]
|
21
|
-
spec.executables = shiteless[Dir::glob("bin/*")].map{|exe| File::basename exe}
|
22
|
-
|
23
|
-
spec.require_path = "lib"
|
24
|
-
|
25
|
-
spec.has_rdoc = true #File::exist? "doc"
|
26
|
-
spec.test_suite_file = "test/#{ $lib }.rb" if File::file?("test/#{ $lib }.rb")
|
27
|
-
#spec.add_dependency 'lib', '>= version'
|
28
|
-
#spec.add_dependency 'fattr'
|
29
|
-
|
30
|
-
spec.extensions << "extconf.rb" if File::exists? "extconf.rb"
|
31
|
-
|
32
|
-
spec.rubyforge_project = 'codeforpeople'
|
33
|
-
spec.author = "Ara T. Howard"
|
34
|
-
spec.email = "ara.t.howard@gmail.com"
|
35
|
-
spec.homepage = "http://codeforpeople.com/lib/ruby/#{ $lib }/"
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
BEGIN{
|
40
|
-
Dir.chdir(File.dirname(__FILE__))
|
41
|
-
$lib = 'tagz'
|
42
|
-
Kernel.load "./lib/#{ $lib }.rb"
|
43
|
-
$version = Tagz.version
|
44
|
-
}
|