dryml 1.3.3 → 1.4.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Gemfile +6 -0
  2. data/README +2 -0
  3. data/Rakefile +2 -1
  4. data/VERSION +1 -1
  5. data/cucumber.yml +9 -0
  6. data/dryml.gemspec +4 -2
  7. data/features/cookbook/01_simple_page_templates.feature +44 -0
  8. data/features/cookbook/02_defining_simple_tags.feature +375 -0
  9. data/features/cookbook/03_implicit_context.feature +229 -0
  10. data/features/cookbook/04_tag_attributes.feature +120 -0
  11. data/features/cookbook/05_repeated_and_optional_content.feature +241 -0
  12. data/features/cookbook/06_pseudo_parameters.feature +191 -0
  13. data/features/cookbook/07_nested_parameters.feature +147 -0
  14. data/features/cookbook/08_customizing_tags.feature +307 -0
  15. data/features/cookbook/09_aliasing_tags.feature +50 -0
  16. data/features/cookbook/10_polymorphic_tags.feature +168 -0
  17. data/features/cookbook/11_wrapping_content.feature +57 -0
  18. data/features/cookbook/12_local_and_scoped_variables.feature +102 -0
  19. data/features/doctest_examples.feature +187 -0
  20. data/features/merge_params.feature +36 -0
  21. data/features/replace_parameters.feature +21 -0
  22. data/features/static_tags.feature +91 -0
  23. data/features/step_definitions/contexts.rb +25 -0
  24. data/features/step_definitions/dom_comparison.rb +10 -0
  25. data/features/step_definitions/rendering.rb +21 -0
  26. data/features/support/env.rb +32 -0
  27. data/features/support/models/author.rb +18 -0
  28. data/features/support/models/blog_post.rb +37 -0
  29. data/features/support/models/discussion.rb +15 -0
  30. data/features/support/models/post.rb +12 -0
  31. data/features/support/strip_formatter.rb +14 -0
  32. data/lib/dryml/dryml_builder.rb +4 -14
  33. data/lib/dryml/dryml_doc.rb +6 -1
  34. data/lib/dryml/helper.rb +17 -1
  35. data/lib/dryml/part_context.rb +12 -15
  36. data/lib/dryml/railtie/template_handler.rb +1 -3
  37. data/lib/dryml/railtie.rb +1 -0
  38. data/lib/dryml/taglib.rb +24 -30
  39. data/lib/dryml/template.rb +32 -86
  40. data/lib/dryml/template_environment.rb +40 -17
  41. data/lib/dryml.rb +22 -11
  42. data/taglibs/core.dryml +18 -12
  43. data/taglibs/dryml.dryml +3 -0
  44. metadata +97 -56
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'hobo_support', :path => '../hobo_support'
4
+
5
+ gemspec
6
+
data/README CHANGED
@@ -1,3 +1,5 @@
1
+ Fundamental tags that can be considered part of the DRYML core language.
2
+
1
3
  # DRYML
2
4
 
3
5
  DRYML is the Don't Repeat Yourself Markup Language. It uses an
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rake'
2
- require 'rake/rdoctask'
2
+ require 'rdoc/task'
3
3
  require 'rake/testtask'
4
4
 
5
5
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
@@ -17,6 +17,7 @@ end
17
17
 
18
18
  # --- RDOC --- #
19
19
 
20
+ require 'rubygems'
20
21
  require 'yard'
21
22
  YARD::Rake::YardocTask.new do |t|
22
23
  t.files = ['lib/**/*.rb', 'README', 'LICENSE.txt', 'CHANGES.txt']
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.3
1
+ 1.4.0.pre2
data/cucumber.yml ADDED
@@ -0,0 +1,9 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--require features --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
9
+
data/dryml.gemspec CHANGED
@@ -11,9 +11,11 @@ Gem::Specification.new do |s|
11
11
  s.summary = "The Don't Repeat Yourself Markup Language"
12
12
  s.description = "The Don't Repeat Yourself Markup Language"
13
13
 
14
- s.add_runtime_dependency('actionpack', ["~> 3.0.0"])
14
+ s.add_runtime_dependency('actionpack', ["~> 3.1.0"])
15
15
  s.add_runtime_dependency('hobo_support', ["= #{version}"])
16
- s.add_development_dependency('rubydoctest', [">= 0"])
16
+ s.add_development_dependency('rubydoctest', [">= 1.1.3"])
17
+ s.add_development_dependency('cucumber', '~> 1.1.0')
18
+ s.add_development_dependency('aruba', '~> 0.4.6')
17
19
 
18
20
  s.files = `git ls-files -x #{name}/* -z`.split("\0")
19
21
 
@@ -0,0 +1,44 @@
1
+ Feature: Simple page templates and ERB
2
+
3
+ Scenario: Interpolating in HTML attributes
4
+ Given a file named "example.dryml" with:
5
+ """
6
+ <% my_url = '/foo/bar' %>
7
+ <a href="#{my_url}">Link Text</a>
8
+ """
9
+ When I render "example.dryml"
10
+ Then the output DOM should be:
11
+ """
12
+ <a href="/foo/bar">Link Text</a>
13
+ """
14
+
15
+ Scenario: Merging a hash of attributes
16
+ Given a file named "example.dryml" with:
17
+ """
18
+ <% hash = { :action => '/foo/bar', :method => 'get' } %>
19
+ <form merge-attrs="&hash">
20
+ <input type="text" name="wut" />
21
+ </form>
22
+ """
23
+ When I render "example.dryml"
24
+ Then the output DOM should be:
25
+ """
26
+ <form action="/foo/bar" method="get">
27
+ <input type="text" name="wut" />
28
+ </form>
29
+ """
30
+
31
+ Scenario: Dynamically calling tags
32
+ Given a file named "example.dryml" with:
33
+ """
34
+ <% my_tag_name = "div" %>
35
+ <%= raw "<#{my_tag_name}>" %>FOO<%= raw "</#{my_tag_name}>" %>
36
+ <call-tag tag="&my_tag_name">BAR</call-tag>
37
+ """
38
+ When I render "example.dryml"
39
+ Then the output DOM should be:
40
+ """
41
+ <div>FOO</div>
42
+ <div>BAR</div>
43
+ """
44
+
@@ -0,0 +1,375 @@
1
+ Feature: Defining simple tags
2
+
3
+ Scenario: A simple tag
4
+ Given a file named "example_taglib.dryml" with:
5
+ """
6
+ <def tag="page">
7
+ <html>
8
+ <head>
9
+ <title>My Blog</title>
10
+ </head>
11
+ <body>
12
+ <h1>My Famous Blog!</h1>
13
+ <h2><%= @post_title %></h2>
14
+
15
+ <div class="post-body">
16
+ <%= @post_body %>
17
+ </div>
18
+ </body>
19
+ </html>
20
+ </def>
21
+ """
22
+ And a file named "example.dryml" with:
23
+ """
24
+ <% @post_title = 'FOO' %>
25
+ <% @post_body = 'Blah blah blah' %>
26
+ <page />
27
+ """
28
+ When I include the taglib "example_taglib"
29
+ And I render "example.dryml"
30
+ Then the output DOM should be:
31
+ """
32
+ <html>
33
+ <head>
34
+ <title>My Blog</title>
35
+ </head>
36
+ <body>
37
+ <h1>My Famous Blog!</h1>
38
+ <h2>FOO</h2>
39
+ <div class="post-body">
40
+ Blah blah blah
41
+ </div>
42
+ </body>
43
+ </html>
44
+ """
45
+
46
+ Scenario: a simple tag with a param
47
+ Given a file named "example_taglib.dryml" with:
48
+ """
49
+ <def tag="page">
50
+ <html>
51
+ <head>
52
+ <title>My Blog</title>
53
+ </head>
54
+ <body param/>
55
+ </html>
56
+ </def>
57
+ """
58
+ And a file named "example.dryml" with:
59
+ """
60
+ <% @post_title = 'FOO' %>
61
+ <% @post_body = 'Blah blah blah' %>
62
+ <page>
63
+ <body:>
64
+ <h1>My Famous Blog!</h1>
65
+ <h2><%= @post_title %></h2>
66
+
67
+ <div class="post-body">
68
+ <%= @post_body %>
69
+ </div>
70
+ </body:>
71
+ </page>
72
+ """
73
+ When I include the taglib "example_taglib"
74
+ And I render "example.dryml"
75
+ Then the output DOM should be:
76
+ """
77
+ <html>
78
+ <head>
79
+ <title>My Blog</title>
80
+ </head>
81
+ <body>
82
+ <h1>My Famous Blog!</h1>
83
+ <h2>FOO</h2>
84
+ <div class="post-body">
85
+ Blah blah blah
86
+ </div>
87
+ </body>
88
+ </html>
89
+ """
90
+ Scenario: a simple tag with a renamed param
91
+ Given a file named "example_taglib.dryml" with:
92
+ """
93
+ <def tag="page">
94
+ <html>
95
+ <head>
96
+ <title>My Blog</title>
97
+ </head>
98
+ <body param="content"/>
99
+ </html>
100
+ </def>
101
+ """
102
+ And a file named "example.dryml" with:
103
+ """
104
+ <% @post_title = 'FOO' %>
105
+ <% @post_body = 'Blah blah blah' %>
106
+ <page>
107
+ <content:>
108
+ <h1>My Famous Blog!</h1>
109
+ <h2><%= @post_title %></h2>
110
+
111
+ <div class="post-body">
112
+ <%= @post_body %>
113
+ </div>
114
+ </content:>
115
+ </page>
116
+ """
117
+ When I include the taglib "example_taglib"
118
+ And I render "example.dryml"
119
+ Then the output DOM should be:
120
+ """
121
+ <html>
122
+ <head>
123
+ <title>My Blog</title>
124
+ </head>
125
+ <body class="content">
126
+ <h1>My Famous Blog!</h1>
127
+ <h2>FOO</h2>
128
+ <div class="post-body">
129
+ Blah blah blah
130
+ </div>
131
+ </body>
132
+ </html>
133
+ """
134
+
135
+ Scenario: a simple tag with two parameters
136
+ Given a file named "example_taglib.dryml" with:
137
+ """
138
+ <def tag="page">
139
+ <html>
140
+ <head>
141
+ <title>My Blog</title>
142
+ </head>
143
+ <body>
144
+ <div param="content" />
145
+ <div param="aside" />
146
+ </body>
147
+ </html>
148
+ </def>
149
+ """
150
+ And a file named "example.dryml" with:
151
+ """
152
+ <% @post_title = 'FOO' %>
153
+ <% @post_body = 'Blah blah blah' %>
154
+ <page>
155
+ <content:>
156
+ <h1>My Famous Blog!</h1>
157
+ <h2><%= @post_title %></h2>
158
+
159
+ <div class="post-body">
160
+ <%= @post_body %>
161
+ </div>
162
+ </content:>
163
+ <aside:>
164
+ Here is some aside content!
165
+ </aside:>
166
+ </page>
167
+ """
168
+ When I include the taglib "example_taglib"
169
+ And I render "example.dryml"
170
+ Then the output DOM should be:
171
+ """
172
+ <html>
173
+ <head>
174
+ <title>My Blog</title>
175
+ </head>
176
+ <body>
177
+ <div class="content">
178
+ <h1>My Famous Blog!</h1>
179
+ <h2>FOO</h2>
180
+ <div class="post-body">
181
+ Blah blah blah
182
+ </div>
183
+ </div>
184
+ <div class="aside">
185
+ Here is some aside content!
186
+ </div>
187
+ </body>
188
+ </html>
189
+ """
190
+
191
+ Scenario: a simple tag with default parameter content
192
+ Given a file named "example_taglib.dryml" with:
193
+ """
194
+ <def tag="page">
195
+ <html>
196
+ <head>
197
+ <title param>My Blog</title>
198
+ </head>
199
+ <body param/>
200
+ </html>
201
+ </def>
202
+ """
203
+ And a file named "example.dryml" with:
204
+ """
205
+ <% @post_title = 'FOO' %>
206
+ <% @post_body = 'Blah blah blah' %>
207
+ <page>
208
+ <title:>My VERY EXCITING Blog</title:>
209
+ <body:>
210
+ <h1>My Famous Blog!</h1>
211
+ <h2><%= @post_title %></h2>
212
+
213
+ <div class="post-body">
214
+ <%= @post_body %>
215
+ </div>
216
+ </body:>
217
+ </page>
218
+ """
219
+ When I include the taglib "example_taglib"
220
+ And I render "example.dryml"
221
+ Then the output DOM should be:
222
+ """
223
+ <html>
224
+ <head>
225
+ <title>My VERY EXCITING Blog</title>
226
+ </head>
227
+ <body>
228
+ <h1>My Famous Blog!</h1>
229
+ <h2>FOO</h2>
230
+ <div class="post-body">
231
+ Blah blah blah
232
+ </div>
233
+ </body>
234
+ </html>
235
+ """
236
+
237
+ Scenario: a simple tag with nested parameters
238
+ Given a file named "example_taglib.dryml" with:
239
+ """
240
+ <def tag="page">
241
+ <html>
242
+ <head>
243
+ <title>My Blog</title>
244
+ </head>
245
+ <body param>
246
+ <div param="content" />
247
+ <div param="aside" />
248
+ </body>
249
+ </html>
250
+ </def>
251
+ """
252
+ And a file named "example.dryml" with:
253
+ """
254
+ <% @post_title = 'FOO' %>
255
+ <% @post_body = 'Blah blah blah' %>
256
+ <page>
257
+ <content:>
258
+ <h1>My Famous Blog!</h1>
259
+ <h2><%= @post_title %></h2>
260
+
261
+ <div class="post-body">
262
+ <%= @post_body %>
263
+ </div>
264
+ </content:>
265
+ <aside:>
266
+ Here is some aside content!
267
+ </aside:>
268
+ </page>
269
+ """
270
+ When I include the taglib "example_taglib"
271
+ And I render "example.dryml"
272
+ Then the output DOM should be:
273
+ """
274
+ <html>
275
+ <head>
276
+ <title>My Blog</title>
277
+ </head>
278
+ <body>
279
+ <div class="content">
280
+ <h1>My Famous Blog!</h1>
281
+ <h2>FOO</h2>
282
+ <div class="post-body">
283
+ Blah blah blah
284
+ </div>
285
+ </div>
286
+ <div class="aside">
287
+ Here is some aside content!
288
+ </div>
289
+ </body>
290
+ </html>
291
+ """
292
+
293
+ Scenario: a simple tag with nested parameters, using the outside param
294
+ Given a file named "example_taglib.dryml" with:
295
+ """
296
+ <def tag="page">
297
+ <html>
298
+ <head>
299
+ <title>My Blog</title>
300
+ </head>
301
+ <body param>
302
+ <div param="content" />
303
+ <div param="aside" />
304
+ </body>
305
+ </html>
306
+ </def>
307
+ """
308
+ And a file named "example.dryml" with:
309
+ """
310
+ <% @post_title = 'FOO' %>
311
+ <% @post_body = 'Blah blah blah' %>
312
+ <page>
313
+ <body:>
314
+ This is body content!
315
+ </body:>
316
+ </page>
317
+ """
318
+ When I include the taglib "example_taglib"
319
+ And I render "example.dryml"
320
+ Then the output DOM should be:
321
+ """
322
+ <html>
323
+ <head>
324
+ <title>My Blog</title>
325
+ </head>
326
+ <body>
327
+ This is body content!
328
+ </body>
329
+ </html>
330
+ """
331
+
332
+ Scenario: a simple tag with a default parameter
333
+ Given a file named "example_taglib.dryml" with:
334
+ """
335
+ <def tag="page">
336
+ <html>
337
+ <head>
338
+ <title>My Blog</title>
339
+ </head>
340
+ <body param="default" />
341
+ </html>
342
+ </def>
343
+ """
344
+ And a file named "example.dryml" with:
345
+ """
346
+ <% @post_title = 'FOO' %>
347
+ <% @post_body = 'Blah blah blah' %>
348
+ <page>
349
+ <h1>My Famous Blog!</h1>
350
+ <h2><%= @post_title %></h2>
351
+
352
+ <div class="post-body">
353
+ <%= @post_body %>
354
+ </div>
355
+ </page>
356
+ """
357
+ When I include the taglib "example_taglib"
358
+ And I render "example.dryml"
359
+ Then the output DOM should be:
360
+ """
361
+ <html>
362
+ <head>
363
+ <title>My Blog</title>
364
+ </head>
365
+ <body>
366
+ <h1>My Famous Blog!</h1>
367
+ <h2>FOO</h2>
368
+ <div class="post-body">
369
+ Blah blah blah
370
+ </div>
371
+ </body>
372
+ </html>
373
+ """
374
+
375
+