w2tags 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. data/COPYING +340 -0
  2. data/LICENSE +6 -0
  3. data/MIT-LICENSE +18 -0
  4. data/Manifest.txt +95 -0
  5. data/README.rdoc +264 -0
  6. data/Rakefile +23 -0
  7. data/VERSION +1 -0
  8. data/bin/w2tags +143 -0
  9. data/doc/ERB.HOT.rdoc +82 -0
  10. data/doc/FAQ.rdoc +81 -0
  11. data/doc/HAML.rdoc +310 -0
  12. data/doc/HOT.rdoc +137 -0
  13. data/doc/History.rdoc +757 -0
  14. data/doc/W2TAGS.rdoc +150 -0
  15. data/example/common.hot +11 -0
  16. data/example/from_readme.erb +78 -0
  17. data/example/from_readme.w2erb +64 -0
  18. data/example/from_w2tags.erb +32 -0
  19. data/example/from_w2tags.w2erb +32 -0
  20. data/example/rails_basic.hot +10 -0
  21. data/hot/erb.hot +156 -0
  22. data/hot/erb_form.hot +42 -0
  23. data/hot/erb_head.hot +15 -0
  24. data/hot/erb_jquery.hot +8 -0
  25. data/hot/erb_merb.hot +12 -0
  26. data/hot/erb_table.hot +43 -0
  27. data/hot/html.hot +31 -0
  28. data/hot/jquery.hot +88 -0
  29. data/hot/nvelocity.hot +23 -0
  30. data/hot/rails/sc_zebra.hot +10 -0
  31. data/hot/rails/scaffold.hot +15 -0
  32. data/hot/vm.hot +9 -0
  33. data/hot/vm2.hot +34 -0
  34. data/hot/vm_crud.hot +34 -0
  35. data/hot/vm_popup.hot +74 -0
  36. data/hot/xul.hot +114 -0
  37. data/lib/w2tags/block/plain_text.rb +57 -0
  38. data/lib/w2tags/block/remark.rb +37 -0
  39. data/lib/w2tags/block/sass.rb +66 -0
  40. data/lib/w2tags/merb_hook.rb +15 -0
  41. data/lib/w2tags/parser.rb +975 -0
  42. data/lib/w2tags/rails_hook.rb +15 -0
  43. data/lib/w2tags/sinatra_hook.rb +50 -0
  44. data/lib/w2tags.rb +100 -0
  45. data/plugins//w2tags//README +2 -0
  46. data/plugins//w2tags//generators//w2scaffold//USAGE +29 -0
  47. data/plugins//w2tags//generators//w2scaffold//templates//controller.rb +85 -0
  48. data/plugins//w2tags//generators//w2scaffold//templates//functional_test.rb +45 -0
  49. data/plugins//w2tags//generators//w2scaffold//templates//helper.rb +2 -0
  50. data/plugins//w2tags//generators//w2scaffold//templates//helper_test.rb +4 -0
  51. data/plugins//w2tags//generators//w2scaffold//templates//layout.html.erb +17 -0
  52. data/plugins//w2tags//generators//w2scaffold//templates//style.css +54 -0
  53. data/plugins//w2tags//generators//w2scaffold//templates//view_edit.html.erb +18 -0
  54. data/plugins//w2tags//generators//w2scaffold//templates//view_edit.html.w2erb +17 -0
  55. data/plugins//w2tags//generators//w2scaffold//templates//view_index.html.erb +24 -0
  56. data/plugins//w2tags//generators//w2scaffold//templates//view_index.html.w2erb +14 -0
  57. data/plugins//w2tags//generators//w2scaffold//templates//view_new.html.erb +17 -0
  58. data/plugins//w2tags//generators//w2scaffold//templates//view_new.html.w2erb +16 -0
  59. data/plugins//w2tags//generators//w2scaffold//templates//view_show.html.erb +10 -0
  60. data/plugins//w2tags//generators//w2scaffold//templates//view_show.html.w2erb +9 -0
  61. data/plugins//w2tags//generators//w2scaffold//w2scaffold_generator.rb +106 -0
  62. data/plugins//w2tags//install.rb +1 -0
  63. data/spec/spec_helper.rb +17 -0
  64. data/spec/w2tags_spec.rb +8 -0
  65. data/tasks/ann.rake +81 -0
  66. data/tasks/bones.rake +21 -0
  67. data/tasks/gem.rake +126 -0
  68. data/tasks/git.rake +41 -0
  69. data/tasks/manifest.rake +49 -0
  70. data/tasks/notes.rake +28 -0
  71. data/tasks/post_load.rake +39 -0
  72. data/tasks/rdoc.rake +51 -0
  73. data/tasks/rubyforge.rake +57 -0
  74. data/tasks/setup.rb +268 -0
  75. data/tasks/spec.rake +55 -0
  76. data/tasks/svn.rake +48 -0
  77. data/tasks/test.rake +38 -0
  78. data/test/enlightning.hot +3 -0
  79. data/test/feature.hot +28 -0
  80. data/test/parser_test.rb +203 -0
  81. data/test/tricky.hot +8 -0
  82. data/test/vars.hot +30 -0
  83. data/test/w2tags_basic_usability.rb +187 -0
  84. data/test/w2tags_enlightning.rb +42 -0
  85. data/test/w2tags_form.rb +32 -0
  86. data/test/w2tags_hot.rb +85 -0
  87. data/test/w2tags_hot_var.rb +115 -0
  88. data/test/w2tags_no_parsing.rb +37 -0
  89. metadata +163 -0
data/doc/HAML.rdoc ADDED
@@ -0,0 +1,310 @@
1
+ == W2TAGS mimics HAML command
2
+
3
+ w2tags mimics HAML command, these are my decission to make it easy for
4
+ users that already use HAML templating engines, but not all command implemented.
5
+
6
+ To new users on HAML, I think is not hard to understand of the HAML command,
7
+ I'll explain basic of W2TAGS HAML like command on w2tags.
8
+
9
+ Rule of W2TAGS HAML like command are:
10
+
11
+ * begin with token ( /[ \t]*TOKEN/ ) of command
12
+ * indentations to make tag have a block of children-tag, or children-tag are
13
+ element of tag with more spaces than parent tag.
14
+ * Auto closing will be added (from previouse tag) if indentations less spaces.
15
+ * Tags-Formating (%) have character that will represent an ID(#), CLASS(.),
16
+ Attribute({}), Ruby Code(=), and Ruby String(==) or I call it Key-Variable.
17
+
18
+ List of HAML command. This list are the HAML command that token begin with:
19
+
20
+ % Tag formating
21
+ # div formating with attribute id
22
+ . div formating with attribute class
23
+ \ line text / no parsing
24
+ - translate to Ruby code
25
+ = translate to Ruby code
26
+ == translate to Ruby String
27
+ -# block remark / comment not include on result
28
+ -! block not parse
29
+
30
+ For details implementation, you must see on each explanation of these command below.
31
+
32
+ === % Tag Formating
33
+
34
+ ==== Basic syntax ( %TAG )
35
+
36
+ %ul
37
+ %li List
38
+ %li New
39
+
40
+ result:
41
+
42
+ <ul>
43
+ <li>List</li>
44
+ <li>New</li>
45
+ </ul>
46
+
47
+ ==== Tag with ID ( %TAG#ID )
48
+
49
+ %ul#menu
50
+
51
+ result:
52
+
53
+ <ul id="menu">
54
+ </ul>
55
+
56
+ ==== Tag with CLASS ( %TAG.CLASS )
57
+
58
+ %ul.main_side
59
+
60
+ result:
61
+
62
+ <ul class="main_side">
63
+ </ul>
64
+
65
+ ==== Tag with ID CLASS ( %TAG#ID.CLASS )
66
+
67
+ %ul#menu.main_side
68
+
69
+ result:
70
+
71
+ <ul id="menu" class="main_side">
72
+ </ul>
73
+
74
+ ==== Tag with Attributes
75
+
76
+ this implementations is difference, on w2tags you type (inside "{}") it
77
+ just like regular attribute must be type.
78
+
79
+ %li.hot{line="1"} List
80
+
81
+ result:
82
+
83
+ <li line="1" class="hot">List</li>
84
+
85
+ ==== Tag with Shortcut to Ruby code (=)
86
+
87
+ %div= @value
88
+
89
+ result:
90
+
91
+ <div><%= @value %></div>
92
+
93
+ ==== Tag with Shortcut to Ruby String (==)
94
+
95
+ %div== #{@value}
96
+
97
+ result:
98
+
99
+ <div><%= "#{@value}" %></div>
100
+
101
+ ==== Rule of Combination
102
+
103
+ Combination of ID, CLASS, Attribute, and "Ruby", just follow from left to the right order,
104
+ you can have all of this or you can ommit some of this, you can check example below:
105
+
106
+ Source:
107
+
108
+ %div#menu.content.light/
109
+ %div#id.class1.class2{row="1"}/
110
+ %div#id.class1/
111
+ %div#id.class2/
112
+ %div#id{row="1"}/
113
+ %div#id/
114
+ %div.class1.class2{row="1"}/
115
+ %div.class2.class1{row="1"}/
116
+ %div.class1{row="1"}/
117
+ %div.class2{row="1"}/
118
+ %div.class1/
119
+ %div.class2/
120
+ %div{row="1"}/
121
+
122
+ Same as:
123
+
124
+ #menu.content.light/
125
+ #id.class1.class2{row="1"}/
126
+ #id.class1/
127
+ #id.class2/
128
+ #id{row="1"}/
129
+ #id/
130
+ .class1.class2{row="1"}/
131
+ .class2.class1{row="1"}/
132
+ .class1{row="1"}/
133
+ .class2{row="1"}/
134
+ .class1/
135
+ .class2/
136
+ %div{row="1"}/
137
+
138
+ Result:
139
+
140
+ <div id="menu" class="content light"/>
141
+ <div id="id" class="class1 class2" row="1"/>
142
+ <div id="id" class="class1"/>
143
+ <div id="id" class="class2"/>
144
+ <div id="id" row="1"/>
145
+ <div id="id"/>
146
+ <div class="class1 class2" row="1"/>
147
+ <div class="class2 class1" row="1"/>
148
+ <div class="class1" row="1"/>
149
+ <div class="class2" row="1"/>
150
+ <div class="class1"/>
151
+ <div class="class2"/>
152
+ <div row="1"/>
153
+
154
+ Source:
155
+
156
+ %div#menu.content.light= Harsojo
157
+ %div#id.class1.class2{row="1"}= Harsojo
158
+ %div#id.class1= Harsojo
159
+ %div#id.class2= Harsojo
160
+ %div#id{row="1"}= Harsojo
161
+ %div#id= Harsojo
162
+ %div.class1.class2{row="1"}= Harsojo
163
+ %div.class2.class1{row="1"}= Harsojo
164
+ %div.class1{row="1"}= Harsojo
165
+ %div.class2{row="1"}= Harsojo
166
+ %div.class1= Harsojo
167
+ %div.class2= Harsojo
168
+ %div{row="1"}= Harsojo
169
+
170
+ result:
171
+
172
+ <div id="menu" class="content light"><%= Harsojo %></div>
173
+ <div id="id" class="class1 class2" row="1"><%= Harsojo %></div>
174
+ <div id="id" class="class1"><%= Harsojo %></div>
175
+ <div id="id" class="class2"><%= Harsojo %></div>
176
+ <div id="id" row="1"><%= Harsojo %></div>
177
+ <div id="id"><%= Harsojo %></div>
178
+ <div class="class1 class2" row="1"><%= Harsojo %></div>
179
+ <div class="class2 class1" row="1"><%= Harsojo %></div>
180
+ <div class="class1" row="1"><%= Harsojo %></div>
181
+ <div class="class2" row="1"><%= Harsojo %></div>
182
+ <div class="class1"><%= Harsojo %></div>
183
+ <div class="class2"><%= Harsojo %></div>
184
+ <div row="1"><%= Harsojo %></div>
185
+
186
+ Source:
187
+
188
+ %div#menu.content.light== Harsojo
189
+ %div#id.class1.class2{row="1"}== Harsojo
190
+ %div#id.class1== Harsojo
191
+ %div#id.class2== Harsojo
192
+ %div#id{row="1"}== Harsojo
193
+ %div#id== Harsojo
194
+ %div.class1.class2{row="1"}== Harsojo
195
+ %div.class2.class1{row="1"}== Harsojo
196
+ %div.class1{row="1"}== Harsojo
197
+ %div.class2{row="1"}== Harsojo
198
+ %div.class1== Harsojo
199
+ %div.class2== Harsojo
200
+ %div{row="1"}== Harsojo
201
+
202
+ result:
203
+
204
+ <div id="menu" class="content light"><%= "Harsojo" %></div>
205
+ <div id="id" class="class1 class2" row="1"><%= "Harsojo" %></div>
206
+ <div id="id" class="class1"><%= "Harsojo" %></div>
207
+ <div id="id" class="class2"><%= "Harsojo" %></div>
208
+ <div id="id" row="1"><%= "Harsojo" %></div>
209
+ <div id="id"><%= "Harsojo" %></div>
210
+ <div class="class1 class2" row="1"><%= "Harsojo" %></div>
211
+ <div class="class2 class1" row="1"><%= "Harsojo" %></div>
212
+ <div class="class1" row="1"><%= "Harsojo" %></div>
213
+ <div class="class2" row="1"><%= "Harsojo" %></div>
214
+ <div class="class1"><%= "Harsojo" %></div>
215
+ <div class="class2"><%= "Harsojo" %></div>
216
+ <div row="1"><%= "Harsojo" %></div>
217
+
218
+ === # or . Shortcut for DIV Tag
219
+ As you can see on the example above, alot of command begin with "%div" and it spoted
220
+ as duplicated and need to refactor :(, luckly you can ommit that tag ("%div"),
221
+ to just write id or class as a HAML command.
222
+
223
+ ==== # div formating with attribute id
224
+
225
+ #main
226
+ %ul#menu.main_side
227
+ %li.hot{line="1"} List
228
+ %li.hot{line="2"} New
229
+
230
+ result:
231
+
232
+ <div id="main">
233
+ <ul id="menu" class="main_side">
234
+ <li line="1" class="hot">List</li>
235
+ <li line="2" class="hot">New</li>
236
+ </ul>
237
+ </div>
238
+
239
+ ==== . div formating with attribute class
240
+
241
+ .content
242
+ %ul#menu.main_side
243
+ %li.hot{line="1"} List
244
+ %li.hot{line="2"} New
245
+
246
+ result:
247
+
248
+ <div class="content">
249
+ <ul id="menu" class="main_side">
250
+ <li line="1" class="hot">List</li>
251
+ <li line="2" class="hot">New</li>
252
+ </ul>
253
+ </div>
254
+
255
+ ==== Other Sample for Shortcut of DIV
256
+
257
+ #menu.content.light/
258
+ #id.class1.class2{row="1"}/
259
+ #id.class1/
260
+ #id.class2/
261
+ #id{row="1"}/
262
+ #id/
263
+ .class1.class2{row="1"}/
264
+ .class2.class1{row="1"}/
265
+ .class1{row="1"}/
266
+ .class2{row="1"}/
267
+ .class1/
268
+ .class2/
269
+
270
+ result:
271
+
272
+ <div id="menu" class="content light"/>
273
+ <div id="id" class="class1 class2" row="1"/>
274
+ <div id="id" class="class1"/>
275
+ <div id="id" class="class2"/>
276
+ <div id="id" row="1"/>
277
+ <div id="id"/>
278
+ <div class="class1 class2" row="1"/>
279
+ <div class="class2 class1" row="1"/>
280
+ <div class="class1" row="1"/>
281
+ <div class="class2" row="1"/>
282
+ <div class="class1"/>
283
+ <div class="class2"/>
284
+
285
+ === \ line text / no parsing
286
+
287
+ when line text begin with \, \ will be ommited and the rest of line will become
288
+ a plain text no parsing to this line.
289
+
290
+ === - translate to Ruby code
291
+
292
+ this is a shortcut that after "-", it put inside of "<% %>"
293
+
294
+ === = translate to Ruby code
295
+
296
+ this is a shortcut that after "=", it put inside of "<%= %>"
297
+
298
+ ==== == translate to Ruby String
299
+
300
+ this is a shortcut that after "=", it put inside of "<%=\" \"%>"
301
+
302
+ === -# block remark / comment not include on result
303
+
304
+ line inside block of indentation (children of) will become a remark / comment
305
+ the result does not have this block
306
+
307
+ === -! block not parse
308
+
309
+ line inside block of indentation (children-tag) will not be parse, this is usefull
310
+ for some block no need to parse ex: javascript.
data/doc/HOT.rdoc ADDED
@@ -0,0 +1,137 @@
1
+ == HOT Files
2
+ by Widi Harsojo, wharsojo.wordpress.com
3
+
4
+ code generate by w2tags are so useable because of the rule translation combine
5
+ with HOT files, in this section I'll explain some of the feature inside it, so
6
+ you will understand how HOT file is working.
7
+
8
+ == PARAMETERS VARIABLE (MAX:9)
9
+
10
+ $*, $0 - $9. When you invoke HOT command like this "-all_params one;two;three;four"
11
+ you are invoking HOT command with 4 parameters ($0,$1,$2,$3), and the translation will
12
+ be done like sample below:
13
+
14
+ >>_all_params
15
+ <div>$*</div>
16
+ -magic $*
17
+ $1
18
+ $0
19
+
20
+ >>_magic
21
+ <magic>$0</magic>
22
+
23
+ $* meaning: this variable will be fill-in after all parameters got fill-in, as example
24
+ we supply 4 parameters and parameters fill in to variable only two ($0 = "one", $1 = "two")
25
+ the rest will go to variable $* = "three;four"
26
+
27
+ !hot!test
28
+ -all_params one;two;three;four
29
+
30
+ <div>three;four</div>
31
+ <magic>three</magic>
32
+ <magic>four</magic>
33
+ two
34
+ one
35
+
36
+ remember passing paramter to HOT doesn't mean that variable must start from
37
+ zero, its only a guide that you can have multiple params to pass in correct order
38
+ see sample after change the HOT but the result still the same
39
+
40
+ >>_all_params
41
+ <div>$*</div>
42
+ -magic $*
43
+ $4
44
+ $3
45
+
46
+ >>_magic
47
+ <magic>$4</magic>
48
+
49
+ == PARAMETERS VARIABLE translate to RUBY CODE ( =$0 )
50
+
51
+ some time it need a block of ruby code / ruby string code inside attribute of tag
52
+ but it must be simple and easy to remember the command and this is how the implementation
53
+
54
+ >>_form
55
+ %form{action="=$0"}
56
+
57
+ -form edit
58
+
59
+ <form action="<%= edit %>">
60
+ </form>
61
+
62
+ == PARAMETERS VARIABLE translate to RUBY STRING CODE ( ==$0 )
63
+
64
+ >>_form2
65
+ %form{action="==$0"}
66
+
67
+ -form edit/1
68
+
69
+ <form action="<%= "edit/1" %>">
70
+ </form>
71
+
72
+ == PARAMETERS VARIABLE INTERPOLATION
73
+
74
+ you can do interpolation on variable
75
+
76
+ >>_all_params
77
+ <div>$*</div>
78
+ -magic $*
79
+ $4
80
+ $3
81
+
82
+ >>_magic
83
+ <magic> $4.upcase.reverse~ </magic>
84
+
85
+ !hot!test
86
+ -all_params one;two;three;four
87
+
88
+ <div>three;four</div>
89
+ <magic> EERHT </magic>
90
+ <magic> RUOF </magic>
91
+ two
92
+ one
93
+
94
+ == PARAMETERS VARIABLE DEFAULT OR COMBINE WITH
95
+
96
+ default mean that is params not supply it will use the default
97
+
98
+ combine mean that is params not supply it will empty params var inside "~ ~$0"
99
+ but if it supply, param var will be replace and remove char "~"
100
+
101
+ test.hot
102
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103
+ >>_all_default
104
+ -default_var $*
105
+ -inside_var $*
106
+
107
+ >>_default_var
108
+ %div{ key="~1~$1" } title 1
109
+ %div{ key="~2~$2" } title 2
110
+ %div{ key="~3~$3" } title 3
111
+
112
+ >>_inside_var
113
+ %div{ ~att="$1"~} title 1
114
+ %div{ ~att="$2"~} title 2
115
+ %div{ ~att="$3"~} title 3
116
+
117
+ params.w2erb
118
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
+ !hot!test
120
+ -all_default one;two
121
+
122
+ params.erb
123
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124
+ <div key="one">title 1</div>
125
+ <div key="two">title 2</div>
126
+ <div key="3">title 3</div>
127
+ <div att="one">title 1</div>
128
+ <div att="two">title 2</div>
129
+ <div>title 3</div>
130
+
131
+ == VARIABLE SET IN SOURCE BUT USE ONLY on HOT
132
+
133
+ * &myvar=value_of_var
134
+ * @myvar=one;two;three
135
+
136
+ on @myvar, it can set multiple time and it will have uniq value
137
+ to reset the value, use value with prefix with ";"