curtain 0.2.0 → 0.3.0

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +311 -17
  3. data/TODO.md +7 -0
  4. data/curtain.gemspec +2 -3
  5. data/erubs_example.rb +103 -0
  6. data/example.erb +4 -0
  7. data/example.slim +2 -0
  8. data/lib/curtain/caching.rb +9 -0
  9. data/lib/curtain/erubis.rb +33 -0
  10. data/lib/curtain/erubis_template.rb +23 -0
  11. data/lib/curtain/form_builder.rb +218 -0
  12. data/lib/curtain/form_helpers.rb +23 -0
  13. data/lib/curtain/html_helpers.rb +180 -0
  14. data/lib/curtain/output_buffer.rb +10 -0
  15. data/lib/curtain/rendering.rb +9 -30
  16. data/lib/curtain/templating.rb +5 -1
  17. data/lib/curtain/version.rb +1 -1
  18. data/lib/curtain.rb +18 -1
  19. data/test/basic_test.rb +66 -0
  20. data/test/cache_test.rb +17 -0
  21. data/test/examples/{body.erb → basic/erb/body.erb} +0 -0
  22. data/test/examples/basic/erb/index.erb +1 -0
  23. data/test/examples/basic/erb/layout.erb +3 -0
  24. data/test/examples/{subdir → basic/erb/subdir}/index.erb +0 -0
  25. data/test/examples/{test.erb → basic/erb/test.erb} +0 -0
  26. data/test/examples/basic/slim/body.slim +5 -0
  27. data/test/examples/basic/slim/index.slim +1 -0
  28. data/test/examples/basic/slim/layout.slim +2 -0
  29. data/test/examples/basic/slim/subdir/index.slim +1 -0
  30. data/test/examples/basic/slim/test.slim +3 -0
  31. data/test/examples/cache/erb/cache.erb +3 -0
  32. data/test/examples/cache/slim/cache.slim +2 -0
  33. data/test/examples/form/Rakefile +56 -0
  34. data/test/examples/form/account.html +101 -0
  35. data/test/examples/form/account.rb +11 -0
  36. data/test/examples/form/account.yml +11 -0
  37. data/test/examples/form/account_view.rb +3 -0
  38. data/test/examples/form/account_with_data.html +100 -0
  39. data/test/examples/form/erb/account.erb +84 -0
  40. data/test/examples/form/erb/account_with_fields.erb +0 -0
  41. data/test/examples/form/erb/bootstrap.erb +15 -0
  42. data/test/examples/form/slim/account.slim +65 -0
  43. data/test/examples/form/slim/bootstrap.slim +11 -0
  44. data/test/examples/html/erb/content_tag.erb +1 -0
  45. data/test/examples/html/erb/content_tag_with_content.erb +1 -0
  46. data/test/examples/html/erb/content_tag_with_content_and_attributes.erb +1 -0
  47. data/test/examples/html/erb/content_tag_with_content_block_and_attributes.erb +3 -0
  48. data/test/examples/html/erb/content_tag_with_content_block_with_nested_tags.erb +3 -0
  49. data/test/examples/html/erb/empty_content_tag.erb +1 -0
  50. data/test/examples/html/erb/void_tag.erb +1 -0
  51. data/test/examples/html/erb/void_tag_with_attributes.erb +1 -0
  52. data/test/examples/html/slim/content_tag.slim +1 -0
  53. data/test/examples/html/slim/content_tag_with_content.slim +1 -0
  54. data/test/examples/html/slim/content_tag_with_content_and_attributes.slim +1 -0
  55. data/test/examples/html/slim/content_tag_with_content_block_and_attributes.slim +2 -0
  56. data/test/examples/html/slim/content_tag_with_content_block_with_nested_tags.slim +2 -0
  57. data/test/examples/html/slim/empty_content_tag.slim +1 -0
  58. data/test/examples/html/slim/void_tag.slim +1 -0
  59. data/test/examples/html/slim/void_tag_with_attributes.slim +1 -0
  60. data/test/form_test.rb +44 -0
  61. data/test/html_test.rb +32 -0
  62. data/test/test_helper.rb +31 -2
  63. metadata +101 -34
  64. data/test/curtain_test.rb +0 -119
  65. data/test/examples/index.erb +0 -1
  66. data/test/examples/layout.erb +0 -1
  67. data/test/examples/registration.mustache +0 -48
  68. data/test/examples/simple.erb +0 -1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curtain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-30 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: haml
56
+ name: glam
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: mustache
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: A template rendering framework
98
84
  email:
99
85
  - mail@paulbarry.com
@@ -107,20 +93,66 @@ files:
107
93
  - LICENSE
108
94
  - README.md
109
95
  - Rakefile
96
+ - TODO.md
110
97
  - curtain.gemspec
98
+ - erubs_example.rb
99
+ - example.erb
100
+ - example.slim
111
101
  - lib/curtain.rb
102
+ - lib/curtain/caching.rb
103
+ - lib/curtain/erubis.rb
104
+ - lib/curtain/erubis_template.rb
105
+ - lib/curtain/form_builder.rb
106
+ - lib/curtain/form_helpers.rb
107
+ - lib/curtain/html_helpers.rb
108
+ - lib/curtain/output_buffer.rb
112
109
  - lib/curtain/rendering.rb
113
110
  - lib/curtain/templating.rb
114
111
  - lib/curtain/variable_support.rb
115
112
  - lib/curtain/version.rb
116
- - test/curtain_test.rb
117
- - test/examples/body.erb
118
- - test/examples/index.erb
119
- - test/examples/layout.erb
120
- - test/examples/registration.mustache
121
- - test/examples/simple.erb
122
- - test/examples/subdir/index.erb
123
- - test/examples/test.erb
113
+ - test/basic_test.rb
114
+ - test/cache_test.rb
115
+ - test/examples/basic/erb/body.erb
116
+ - test/examples/basic/erb/index.erb
117
+ - test/examples/basic/erb/layout.erb
118
+ - test/examples/basic/erb/subdir/index.erb
119
+ - test/examples/basic/erb/test.erb
120
+ - test/examples/basic/slim/body.slim
121
+ - test/examples/basic/slim/index.slim
122
+ - test/examples/basic/slim/layout.slim
123
+ - test/examples/basic/slim/subdir/index.slim
124
+ - test/examples/basic/slim/test.slim
125
+ - test/examples/cache/erb/cache.erb
126
+ - test/examples/cache/slim/cache.slim
127
+ - test/examples/form/Rakefile
128
+ - test/examples/form/account.html
129
+ - test/examples/form/account.rb
130
+ - test/examples/form/account.yml
131
+ - test/examples/form/account_view.rb
132
+ - test/examples/form/account_with_data.html
133
+ - test/examples/form/erb/account.erb
134
+ - test/examples/form/erb/account_with_fields.erb
135
+ - test/examples/form/erb/bootstrap.erb
136
+ - test/examples/form/slim/account.slim
137
+ - test/examples/form/slim/bootstrap.slim
138
+ - test/examples/html/erb/content_tag.erb
139
+ - test/examples/html/erb/content_tag_with_content.erb
140
+ - test/examples/html/erb/content_tag_with_content_and_attributes.erb
141
+ - test/examples/html/erb/content_tag_with_content_block_and_attributes.erb
142
+ - test/examples/html/erb/content_tag_with_content_block_with_nested_tags.erb
143
+ - test/examples/html/erb/empty_content_tag.erb
144
+ - test/examples/html/erb/void_tag.erb
145
+ - test/examples/html/erb/void_tag_with_attributes.erb
146
+ - test/examples/html/slim/content_tag.slim
147
+ - test/examples/html/slim/content_tag_with_content.slim
148
+ - test/examples/html/slim/content_tag_with_content_and_attributes.slim
149
+ - test/examples/html/slim/content_tag_with_content_block_and_attributes.slim
150
+ - test/examples/html/slim/content_tag_with_content_block_with_nested_tags.slim
151
+ - test/examples/html/slim/empty_content_tag.slim
152
+ - test/examples/html/slim/void_tag.slim
153
+ - test/examples/html/slim/void_tag_with_attributes.slim
154
+ - test/form_test.rb
155
+ - test/html_test.rb
124
156
  - test/test_helper.rb
125
157
  homepage: http://github.com/pjb3/curtain
126
158
  licenses: []
@@ -141,18 +173,53 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
173
  version: '0'
142
174
  requirements: []
143
175
  rubyforge_project:
144
- rubygems_version: 2.0.0
176
+ rubygems_version: 2.0.14
145
177
  signing_key:
146
178
  specification_version: 4
147
179
  summary: A template rendering framework
148
180
  test_files:
149
- - test/curtain_test.rb
150
- - test/examples/body.erb
151
- - test/examples/index.erb
152
- - test/examples/layout.erb
153
- - test/examples/registration.mustache
154
- - test/examples/simple.erb
155
- - test/examples/subdir/index.erb
156
- - test/examples/test.erb
181
+ - test/basic_test.rb
182
+ - test/cache_test.rb
183
+ - test/examples/basic/erb/body.erb
184
+ - test/examples/basic/erb/index.erb
185
+ - test/examples/basic/erb/layout.erb
186
+ - test/examples/basic/erb/subdir/index.erb
187
+ - test/examples/basic/erb/test.erb
188
+ - test/examples/basic/slim/body.slim
189
+ - test/examples/basic/slim/index.slim
190
+ - test/examples/basic/slim/layout.slim
191
+ - test/examples/basic/slim/subdir/index.slim
192
+ - test/examples/basic/slim/test.slim
193
+ - test/examples/cache/erb/cache.erb
194
+ - test/examples/cache/slim/cache.slim
195
+ - test/examples/form/Rakefile
196
+ - test/examples/form/account.html
197
+ - test/examples/form/account.rb
198
+ - test/examples/form/account.yml
199
+ - test/examples/form/account_view.rb
200
+ - test/examples/form/account_with_data.html
201
+ - test/examples/form/erb/account.erb
202
+ - test/examples/form/erb/account_with_fields.erb
203
+ - test/examples/form/erb/bootstrap.erb
204
+ - test/examples/form/slim/account.slim
205
+ - test/examples/form/slim/bootstrap.slim
206
+ - test/examples/html/erb/content_tag.erb
207
+ - test/examples/html/erb/content_tag_with_content.erb
208
+ - test/examples/html/erb/content_tag_with_content_and_attributes.erb
209
+ - test/examples/html/erb/content_tag_with_content_block_and_attributes.erb
210
+ - test/examples/html/erb/content_tag_with_content_block_with_nested_tags.erb
211
+ - test/examples/html/erb/empty_content_tag.erb
212
+ - test/examples/html/erb/void_tag.erb
213
+ - test/examples/html/erb/void_tag_with_attributes.erb
214
+ - test/examples/html/slim/content_tag.slim
215
+ - test/examples/html/slim/content_tag_with_content.slim
216
+ - test/examples/html/slim/content_tag_with_content_and_attributes.slim
217
+ - test/examples/html/slim/content_tag_with_content_block_and_attributes.slim
218
+ - test/examples/html/slim/content_tag_with_content_block_with_nested_tags.slim
219
+ - test/examples/html/slim/empty_content_tag.slim
220
+ - test/examples/html/slim/void_tag.slim
221
+ - test/examples/html/slim/void_tag_with_attributes.slim
222
+ - test/form_test.rb
223
+ - test/html_test.rb
157
224
  - test/test_helper.rb
158
225
  has_rdoc:
data/test/curtain_test.rb DELETED
@@ -1,119 +0,0 @@
1
- puts $:
2
- require 'test_helper'
3
-
4
- class CurtainTest < Test::Unit::TestCase
5
-
6
- # Using the top-level to test default template name behavior
7
- class ::TestView < Curtain::View
8
- self.template_directories = File.join(File.dirname(__FILE__), "examples")
9
-
10
- attr_accessor :name
11
-
12
- def shout(s)
13
- s.upcase
14
- end
15
- end
16
-
17
- class Account
18
- attr_accessor :email, :password, :first_name, :last_name, :gender, :date_of_birth
19
-
20
- def initialize(attrs={})
21
- if attrs
22
- attrs.each do |attr, value|
23
- send("#{attr}=", value)
24
- end
25
- end
26
- end
27
- end
28
-
29
- class ::RegistrationView < TestView
30
-
31
- attr_accessor :account, :errors
32
-
33
- delegate :email, :first_name, :last_name, :gender, :date_of_birth, :to => :account
34
-
35
- def date_of_birth_day_options
36
- [{}] + (1..31).map do |day|
37
- { text: day, value: day, selected: day == date_of_birth.try(:day) }
38
- end
39
- end
40
-
41
- def date_of_birth_month_options
42
- Date::ABBR_MONTHNAMES.each_with_index.map do |month, i|
43
- { text: month, value: i > 0 ? 1 : nil, selected: i == date_of_birth.try(:month) ? 'selected' : nil }
44
- end
45
- end
46
-
47
- def date_of_birth_year_options
48
- [{}] + 13.years.ago.year.downto(113.years.ago.year).map do |year|
49
- { text: year, value: year, selected: year == date_of_birth.try(:year) ? 'selected' : nil }
50
- end
51
- end
52
- end
53
-
54
- class SubdirView < Curtain::View
55
- template :index
56
- end
57
-
58
- SubdirView.template_directories = [File.join(File.dirname(__FILE__), "examples", "subdir")] + Curtain::View.template_directories
59
-
60
- def test_render_default
61
- view = TestView.new
62
- assert_equal "<h1>TEST</h1>\n", view.render
63
- end
64
-
65
- def test_render_default_with_locals
66
- view = TestView.new
67
- assert_equal "<h1>TEST</h1>\n <p>Hello, World!</p>\n", view.render(:msg => "Hello, World!")
68
- end
69
-
70
- def test_render_template
71
- view = TestView.new
72
- assert_equal "<h1>default</h1>\n", view.render(:index)
73
- end
74
-
75
- def test_render_template_with_locals
76
- view = TestView.new
77
- assert_equal "<h1>Hello, World!</h1>\n", view.render(:index, :msg => "Hello, World!")
78
- end
79
-
80
- def test_render_multiple_template_directories
81
- view = SubdirView.new
82
- assert_equal "<h1>Subdir</h1>\n", view.render
83
- end
84
-
85
- def test_variables_and_render_within_template
86
- view = TestView.new
87
- view[:msg] = "Hello, World!"
88
- assert_equal "<html><body><h1>Hello, World!</h1>\n</body></html>\n", view.render("layout", :main => "body")
89
- end
90
-
91
- def test_mustache_form
92
- expected = remove_whitespace(%{<h2>Register</h2>
93
- <form action="/register">
94
- <label class="block">
95
- Email:
96
- <input type="type" name="email" value="mail@paulbarry.com" />
97
- </label>
98
- <label class="block">
99
- Password:
100
- <input type="password" name="password" />
101
- </label>
102
- <label class="block">
103
- First Name:
104
- <input type="text" name="first_name" value="" />
105
- </label>
106
- <button type="submit" class="btn btn-primary">Log In</button>
107
- </form>})
108
-
109
- view = RegistrationView.new(account: Account.new(email: 'mail@paulbarry.com', date_of_birth: Date.parse('1978-07-06')))
110
- puts view.render
111
- assert_equal expected, remove_whitespace(view.render)
112
- end
113
-
114
- private
115
- def remove_whitespace(s)
116
- s.to_s.split("\n").map(&:strip).reject(&:blank?).join("\n")
117
- end
118
-
119
- end
@@ -1 +0,0 @@
1
- <h1><%= defined?(msg) ? msg : 'default' %></h1>
@@ -1 +0,0 @@
1
- <html><body><%= render main %></body></html>
@@ -1,48 +0,0 @@
1
- <h2>Register</h2>
2
- <form action="/register">
3
-
4
- {{#errors}}
5
- <div class="error">
6
- {{ msg }}
7
- </div>
8
- {{/errors}}
9
-
10
- <label class="block">
11
- Email:
12
- <input type="type" name="email" value="{{ email }}" />
13
- </label>
14
-
15
- <label class="block">
16
- Password:
17
- <input type="password" name="password" />
18
- </label>
19
-
20
- <label class="block">
21
- First Name:
22
- <input type="text" name="first_name" value="{{ first_name }}" />
23
- </label>
24
-
25
- <label class="block">
26
- Date of Birth:
27
-
28
- <select name="date_of_birth[month]">
29
- {{#date_of_birth_month_options}}
30
- <option value="{{ value }}"{{#selected}} selected="selected"{{/selected}}>{{ text }}</option>
31
- {{/date_of_birth_month_options}}
32
- </select>
33
-
34
- <select name="date_of_birth[day]">
35
- {{#date_of_birth_day_options}}
36
- <option value="{{ value }}"{{#selected}} selected="selected"{{/selected}}>{{ text }}</option>
37
- {{/date_of_birth_day_options}}
38
- </select>
39
-
40
- <select name="date_of_birth[year]">
41
- {{#date_of_birth_year_options}}
42
- <option value="{{ value }}"{{#selected}} selected="selected"{{/selected}}>{{ text }}</option>
43
- {{/date_of_birth_year_options}}
44
- </select>
45
- </label>
46
-
47
- <button type="submit" class="btn btn-primary">Log In</button>
48
- </form>
@@ -1 +0,0 @@
1
- <%= msg %>