tagz 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +240 -0
- data/README.tmpl +240 -0
- data/install.rb +4 -0
- data/lib/tagz.rb +146 -351
- data/test/tagz.rb +226 -191
- metadata +3 -106
- data/lib/tagz/rails.rb +0 -198
- data/rails/README +0 -182
- data/rails/Rakefile +0 -10
- data/rails/app/controllers/application.rb +0 -7
- data/rails/app/controllers/tagz_controller.rb +0 -51
- data/rails/app/helpers/application_helper.rb +0 -3
- data/rails/app/helpers/tagz_helper.rb +0 -2
- data/rails/app/views/layouts/layout.rb +0 -16
- data/rails/app/views/tagz/b.rb +0 -19
- data/rails/app/views/tagz/c.rb +0 -9
- data/rails/app/views/tagz/d.rhtml +0 -17
- data/rails/app/views/tagz/e.rb +0 -3
- data/rails/config/boot.rb +0 -45
- data/rails/config/database.yml +0 -36
- data/rails/config/environment.rb +0 -65
- data/rails/config/environments/development.rb +0 -21
- data/rails/config/environments/production.rb +0 -18
- data/rails/config/environments/test.rb +0 -19
- data/rails/config/lighttpd.conf +0 -54
- data/rails/config/routes.rb +0 -23
- data/rails/doc/README_FOR_APP +0 -2
- data/rails/log/development.log +0 -6713
- data/rails/log/fastcgi.crash.log +0 -103
- data/rails/log/lighttpd.access.log +0 -171
- data/rails/log/lighttpd.error.log +0 -116
- data/rails/log/production.log +0 -0
- data/rails/log/server.log +0 -0
- data/rails/log/test.log +0 -0
- data/rails/public/404.html +0 -30
- data/rails/public/500.html +0 -30
- data/rails/public/dispatch.cgi +0 -10
- data/rails/public/dispatch.fcgi +0 -24
- data/rails/public/dispatch.rb +0 -10
- data/rails/public/favicon.ico +0 -0
- data/rails/public/images/rails.png +0 -0
- data/rails/public/index.html +0 -277
- data/rails/public/javascripts/application.js +0 -2
- data/rails/public/javascripts/controls.js +0 -833
- data/rails/public/javascripts/dragdrop.js +0 -942
- data/rails/public/javascripts/effects.js +0 -1088
- data/rails/public/javascripts/prototype.js +0 -2515
- data/rails/public/robots.txt +0 -1
- data/rails/script/about +0 -3
- data/rails/script/breakpointer +0 -3
- data/rails/script/console +0 -3
- data/rails/script/destroy +0 -3
- data/rails/script/generate +0 -3
- data/rails/script/performance/benchmarker +0 -3
- data/rails/script/performance/profiler +0 -3
- data/rails/script/plugin +0 -3
- data/rails/script/process/inspector +0 -3
- data/rails/script/process/reaper +0 -3
- data/rails/script/process/spawner +0 -3
- data/rails/script/runner +0 -3
- data/rails/script/server +0 -4
- data/rails/test/functional/tagz_controller_test.rb +0 -18
- data/rails/test/test_helper.rb +0 -28
- data/rails/tmp/cache/index.html-gzip-1958902-7552-1181801882 +0 -0
- data/rails/tmp/cache/javascripts/effects.js-gzip-1958907-38200-1181801882 +0 -0
- data/rails/tmp/cache/javascripts/prototype.js-gzip-1958906-71260-1181801882 +0 -0
- data/rails/tmp/sessions/ruby_sess.365e696810aa7418 +0 -0
- data/rails/tmp/sessions/ruby_sess.3ab0cb2f589d3855 +0 -0
- data/rails/tmp/sessions/ruby_sess.c812e68d96a6e99f +0 -0
- data/rails/tmp/sessions/ruby_sess.e0a954440a7e27d7 +0 -0
data/README
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
NAME
|
2
|
+
tagz.rb
|
3
|
+
|
4
|
+
SYNOPSIS
|
5
|
+
object mixin for squeaky clean and super speedy generation of any sgml
|
6
|
+
(html/xml) tags using a private dsl
|
7
|
+
|
8
|
+
+ module level interface
|
9
|
+
|
10
|
+
require 'tagz'
|
11
|
+
|
12
|
+
html =
|
13
|
+
Tagz{
|
14
|
+
html_{
|
15
|
+
body_(:class => 'container'){
|
16
|
+
div_{ 'content' }
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
+ private mixin interface
|
22
|
+
|
23
|
+
require 'tagz'
|
24
|
+
|
25
|
+
class Table < ::Array
|
26
|
+
include Tagz
|
27
|
+
|
28
|
+
def initialize width, height
|
29
|
+
@width, @height = width, height
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_row
|
33
|
+
Tagz{
|
34
|
+
table_(:width => @width, :height => @height){
|
35
|
+
each do |row|
|
36
|
+
tr_{
|
37
|
+
row.each{|cell| td_{ cell }}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
DESCRIPTION
|
46
|
+
tagz.rb offers a mixin module which adds four private methods to the calling
|
47
|
+
object:
|
48
|
+
|
49
|
+
tagz
|
50
|
+
tagz__
|
51
|
+
__tagz
|
52
|
+
method_missing
|
53
|
+
|
54
|
+
because the mixing adds only private methods it's safe to use, for instance,
|
55
|
+
in the controller of a web framework which exposes methods to the world as
|
56
|
+
http actions
|
57
|
+
|
58
|
+
the method_missing tagz.rb adds *only* works from inside a Tagz{}/tagz{}
|
59
|
+
block, for instance
|
60
|
+
|
61
|
+
include Tagz
|
62
|
+
|
63
|
+
tagz{ h1_{ 'this works' } }
|
64
|
+
|
65
|
+
h1_{ 'this throws NameError' }
|
66
|
+
|
67
|
+
tagz.rb is very non-restrictive, allowing you to generate invalid html,
|
68
|
+
html4, xml, whatever, all using the same simple interface
|
69
|
+
|
70
|
+
for example
|
71
|
+
|
72
|
+
require 'tagz'
|
73
|
+
include Tagz
|
74
|
+
|
75
|
+
tagz{
|
76
|
+
div_(:class => 'pinky'){ 'content' }
|
77
|
+
}
|
78
|
+
|
79
|
+
#=> <div class="pinky">content</div>
|
80
|
+
|
81
|
+
|
82
|
+
tagz{
|
83
|
+
img_(:src => 'foo.png')
|
84
|
+
img_(:src => 'foo.png'){}
|
85
|
+
}
|
86
|
+
|
87
|
+
#=> <img src="foo.png">
|
88
|
+
#=> <img src="foo.png" />
|
89
|
+
|
90
|
+
|
91
|
+
tagz{
|
92
|
+
br_
|
93
|
+
br_!
|
94
|
+
br_{}
|
95
|
+
}
|
96
|
+
|
97
|
+
#=> <br>
|
98
|
+
#=> <br />
|
99
|
+
#=> <br />
|
100
|
+
|
101
|
+
|
102
|
+
tagz{
|
103
|
+
span_('content', :style => 'color:mauve')
|
104
|
+
}
|
105
|
+
|
106
|
+
#=> <span style="color:mauve">content</span>
|
107
|
+
|
108
|
+
|
109
|
+
tagz{
|
110
|
+
div_(:class => 'container'){
|
111
|
+
span_('content', :style => 'color:mauve')
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
#=> <div class="container"><span style="color:mauve">content</span></div>
|
116
|
+
|
117
|
+
|
118
|
+
tagz{
|
119
|
+
div_(:class => 'container')
|
120
|
+
span_('content', :style => 'color:mauve')
|
121
|
+
_div
|
122
|
+
}
|
123
|
+
|
124
|
+
#=> <div class="container"><span style="color:mauve">content</span></div>
|
125
|
+
|
126
|
+
|
127
|
+
tagz{
|
128
|
+
table_(:width => 42{
|
129
|
+
%w( 1 2 3 ).each do |row|
|
130
|
+
tr_{
|
131
|
+
row.each{|cell| td_{ cell }}
|
132
|
+
}
|
133
|
+
end
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
#=> <table width="42"><tr><td>1</td><td>2</td><td>3</td></tr></table>
|
138
|
+
|
139
|
+
# note that the return value of the table block ( the array %w( 1 2 3 )
|
140
|
+
# is *NOT* added to the content. the rule is: add the return value of
|
141
|
+
# the block if, and only if, the block did not add any content itself
|
142
|
+
# during evaluation
|
143
|
+
|
144
|
+
|
145
|
+
tagz{
|
146
|
+
div_{
|
147
|
+
div_{ 'content' }
|
148
|
+
'this is ignored'
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
#=> <div><div>content</div></div>
|
153
|
+
|
154
|
+
# this is a side effect of the above rule
|
155
|
+
|
156
|
+
|
157
|
+
tagz{
|
158
|
+
div_{
|
159
|
+
'this is not ignored, see above rule'
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
#=> <div>this is not ignored, see above rule</div>
|
164
|
+
|
165
|
+
|
166
|
+
tagz{
|
167
|
+
div_{
|
168
|
+
div_{ 'content' }
|
169
|
+
tagz << 'this is appended' << ' and so is this'
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
#=> <div><div>content</div>this is appended and so is this</div>
|
174
|
+
|
175
|
+
|
176
|
+
tagz{
|
177
|
+
a_
|
178
|
+
b_
|
179
|
+
c_
|
180
|
+
tagz << 'valid html'
|
181
|
+
_a
|
182
|
+
_b
|
183
|
+
_c
|
184
|
+
_invalid
|
185
|
+
}
|
186
|
+
|
187
|
+
#=> <a><b><c>valid html</a></b></c></invalid>
|
188
|
+
|
189
|
+
|
190
|
+
tagz{
|
191
|
+
__
|
192
|
+
a_{ 'content' }
|
193
|
+
|
194
|
+
__ __
|
195
|
+
b_{ 'content' }
|
196
|
+
|
197
|
+
__ __ __
|
198
|
+
c_{ 'content' }
|
199
|
+
}
|
200
|
+
|
201
|
+
#=> \n<a>content</a>\n\n<b>content</b>\n\n\n<c>content</c>
|
202
|
+
|
203
|
+
# note that \n is newline. the html tagz generates is quite compact,
|
204
|
+
# you can do 'tagz << "\n"' or just use the '__' method to output some
|
205
|
+
# linebreaks
|
206
|
+
|
207
|
+
|
208
|
+
tagz{
|
209
|
+
link = e(:a, :href => 'foo.com'){ 'link text' }
|
210
|
+
|
211
|
+
div_{ link }
|
212
|
+
}
|
213
|
+
|
214
|
+
#=> <div><a href="foo.com">link text</a>
|
215
|
+
|
216
|
+
|
217
|
+
a couple of notes: *none* of the method_missing magic is available outside
|
218
|
+
the 'tagz' block and, even inside, it supers-up when the missing method does
|
219
|
+
not look like a tag method. you can use Tagz{} as a module method but to
|
220
|
+
have access to @ivars you'll want to mixin the module to your own class and
|
221
|
+
use tagz{}. no public methods are added to your object, only four private
|
222
|
+
ones.
|
223
|
+
|
224
|
+
|
225
|
+
HISTORY
|
226
|
+
1.0.0
|
227
|
+
totally reworked tagz, dropping 300 loc - only 170 loc now. this release
|
228
|
+
is *NOT* backward compatible with other tagz versions, though the api is
|
229
|
+
very very close. the rework makes tagz safer to mixin, faster, and
|
230
|
+
produces nicer looking html. this version also marks ramaze template
|
231
|
+
support.
|
232
|
+
|
233
|
+
INSTALL
|
234
|
+
gem install tagz
|
235
|
+
|
236
|
+
URI
|
237
|
+
http://rubyforge.org/projects/codeforpeople
|
238
|
+
|
239
|
+
AUTHOR
|
240
|
+
ara.t.howard@gmail.com
|
data/README.tmpl
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
NAME
|
2
|
+
tagz.rb
|
3
|
+
|
4
|
+
SYNOPSIS
|
5
|
+
object mixin for squeaky clean and super speedy generation of any sgml
|
6
|
+
(html/xml) tags using a private dsl
|
7
|
+
|
8
|
+
+ module level interface
|
9
|
+
|
10
|
+
require 'tagz'
|
11
|
+
|
12
|
+
html =
|
13
|
+
Tagz{
|
14
|
+
html_{
|
15
|
+
body_(:class => 'container'){
|
16
|
+
div_{ 'content' }
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
+ private mixin interface
|
22
|
+
|
23
|
+
require 'tagz'
|
24
|
+
|
25
|
+
class Table < ::Array
|
26
|
+
include Tagz
|
27
|
+
|
28
|
+
def initialize width, height
|
29
|
+
@width, @height = width, height
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_row
|
33
|
+
Tagz{
|
34
|
+
table_(:width => @width, :height => @height){
|
35
|
+
each do |row|
|
36
|
+
tr_{
|
37
|
+
row.each{|cell| td_{ cell }}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
DESCRIPTION
|
46
|
+
tagz.rb offers a mixin module which adds four private methods to the calling
|
47
|
+
object:
|
48
|
+
|
49
|
+
tagz
|
50
|
+
tagz__
|
51
|
+
__tagz
|
52
|
+
method_missing
|
53
|
+
|
54
|
+
because the mixing adds only private methods it's safe to use, for instance,
|
55
|
+
in the controller of a web framework which exposes methods to the world as
|
56
|
+
http actions
|
57
|
+
|
58
|
+
the method_missing tagz.rb adds *only* works from inside a Tagz{}/tagz{}
|
59
|
+
block, for instance
|
60
|
+
|
61
|
+
include Tagz
|
62
|
+
|
63
|
+
tagz{ h1_{ 'this works' } }
|
64
|
+
|
65
|
+
h1_{ 'this throws NameError' }
|
66
|
+
|
67
|
+
tagz.rb is very non-restrictive, allowing you to generate invalid html,
|
68
|
+
html4, xml, whatever, all using the same simple interface
|
69
|
+
|
70
|
+
for example
|
71
|
+
|
72
|
+
require 'tagz'
|
73
|
+
include Tagz
|
74
|
+
|
75
|
+
tagz{
|
76
|
+
div_(:class => 'pinky'){ 'content' }
|
77
|
+
}
|
78
|
+
|
79
|
+
#=> <div class="pinky">content</div>
|
80
|
+
|
81
|
+
|
82
|
+
tagz{
|
83
|
+
img_(:src => 'foo.png')
|
84
|
+
img_(:src => 'foo.png'){}
|
85
|
+
}
|
86
|
+
|
87
|
+
#=> <img src="foo.png">
|
88
|
+
#=> <img src="foo.png" />
|
89
|
+
|
90
|
+
|
91
|
+
tagz{
|
92
|
+
br_
|
93
|
+
br_!
|
94
|
+
br_{}
|
95
|
+
}
|
96
|
+
|
97
|
+
#=> <br>
|
98
|
+
#=> <br />
|
99
|
+
#=> <br />
|
100
|
+
|
101
|
+
|
102
|
+
tagz{
|
103
|
+
span_('content', :style => 'color:mauve')
|
104
|
+
}
|
105
|
+
|
106
|
+
#=> <span style="color:mauve">content</span>
|
107
|
+
|
108
|
+
|
109
|
+
tagz{
|
110
|
+
div_(:class => 'container'){
|
111
|
+
span_('content', :style => 'color:mauve')
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
#=> <div class="container"><span style="color:mauve">content</span></div>
|
116
|
+
|
117
|
+
|
118
|
+
tagz{
|
119
|
+
div_(:class => 'container')
|
120
|
+
span_('content', :style => 'color:mauve')
|
121
|
+
_div
|
122
|
+
}
|
123
|
+
|
124
|
+
#=> <div class="container"><span style="color:mauve">content</span></div>
|
125
|
+
|
126
|
+
|
127
|
+
tagz{
|
128
|
+
table_(:width => 42{
|
129
|
+
%w( 1 2 3 ).each do |row|
|
130
|
+
tr_{
|
131
|
+
row.each{|cell| td_{ cell }}
|
132
|
+
}
|
133
|
+
end
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
#=> <table width="42"><tr><td>1</td><td>2</td><td>3</td></tr></table>
|
138
|
+
|
139
|
+
# note that the return value of the table block ( the array %w( 1 2 3 )
|
140
|
+
# is *NOT* added to the content. the rule is: add the return value of
|
141
|
+
# the block if, and only if, the block did not add any content itself
|
142
|
+
# during evaluation
|
143
|
+
|
144
|
+
|
145
|
+
tagz{
|
146
|
+
div_{
|
147
|
+
div_{ 'content' }
|
148
|
+
'this is ignored'
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
#=> <div><div>content</div></div>
|
153
|
+
|
154
|
+
# this is a side effect of the above rule
|
155
|
+
|
156
|
+
|
157
|
+
tagz{
|
158
|
+
div_{
|
159
|
+
'this is not ignored, see above rule'
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
#=> <div>this is not ignored, see above rule</div>
|
164
|
+
|
165
|
+
|
166
|
+
tagz{
|
167
|
+
div_{
|
168
|
+
div_{ 'content' }
|
169
|
+
tagz << 'this is appended' << ' and so is this'
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
#=> <div><div>content</div>this is appended and so is this</div>
|
174
|
+
|
175
|
+
|
176
|
+
tagz{
|
177
|
+
a_
|
178
|
+
b_
|
179
|
+
c_
|
180
|
+
tagz << 'valid html'
|
181
|
+
_a
|
182
|
+
_b
|
183
|
+
_c
|
184
|
+
_invalid
|
185
|
+
}
|
186
|
+
|
187
|
+
#=> <a><b><c>valid html</a></b></c></invalid>
|
188
|
+
|
189
|
+
|
190
|
+
tagz{
|
191
|
+
__
|
192
|
+
a_{ 'content' }
|
193
|
+
|
194
|
+
__ __
|
195
|
+
b_{ 'content' }
|
196
|
+
|
197
|
+
__ __ __
|
198
|
+
c_{ 'content' }
|
199
|
+
}
|
200
|
+
|
201
|
+
#=> \n<a>content</a>\n\n<b>content</b>\n\n\n<c>content</c>
|
202
|
+
|
203
|
+
# note that \n is newline. the html tagz generates is quite compact,
|
204
|
+
# you can do 'tagz << "\n"' or just use the '__' method to output some
|
205
|
+
# linebreaks
|
206
|
+
|
207
|
+
|
208
|
+
tagz{
|
209
|
+
link = e(:a, :href => 'foo.com'){ 'link text' }
|
210
|
+
|
211
|
+
div_{ link }
|
212
|
+
}
|
213
|
+
|
214
|
+
#=> <div><a href="foo.com">link text</a>
|
215
|
+
|
216
|
+
|
217
|
+
a couple of notes: *none* of the method_missing magic is available outside
|
218
|
+
the 'tagz' block and, even inside, it supers-up when the missing method does
|
219
|
+
not look like a tag method. you can use Tagz{} as a module method but to
|
220
|
+
have access to @ivars you'll want to mixin the module to your own class and
|
221
|
+
use tagz{}. no public methods are added to your object, only four private
|
222
|
+
ones.
|
223
|
+
|
224
|
+
|
225
|
+
HISTORY
|
226
|
+
1.0.0
|
227
|
+
totally reworked tagz, dropping 300 loc - only 170 loc now. this release
|
228
|
+
is *NOT* backward compatible with other tagz versions, though the api is
|
229
|
+
very very close. the rework makes tagz safer to mixin, faster, and
|
230
|
+
produces nicer looking html. this version also marks ramaze template
|
231
|
+
support.
|
232
|
+
|
233
|
+
INSTALL
|
234
|
+
gem install tagz
|
235
|
+
|
236
|
+
URI
|
237
|
+
http://rubyforge.org/projects/codeforpeople
|
238
|
+
|
239
|
+
AUTHOR
|
240
|
+
ara.t.howard@gmail.com
|