blot 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a786bd43a519269a7e46fe60f9400a84b4f7f972
4
- data.tar.gz: 4793aa337c554b481e64f5d0e108615d16deac08
3
+ metadata.gz: 75fb82eb36721ba625375899e41786b2f1af8dd9
4
+ data.tar.gz: aeb72d5a8b0e61f2a0230c254e6bf9204bf21358
5
5
  SHA512:
6
- metadata.gz: d7638da818a17bd9ed9d7aece291060b403f686c73c8a668755a23a5d2189959b37dc27eec82212fe68d8882a9cfede8d501660ad62bea2533c99e461d5cee13
7
- data.tar.gz: 525bec7f37bdfcd6dae2ff2f115ed3e833dfcc1eba9db39358f0f07db7d8355e696d6cfddd8303f643b6d5ead77b9f158a1d8a37e341e4f86c80beb675f55ec8
6
+ metadata.gz: 2befd7af52d2815d14e87587d2db752460602a5d8fb4525d5164b822f88ef601625244311dab11aa40fd4c1d7a8e8db813e878ac6359bc996079b60425d5862b
7
+ data.tar.gz: 23042442e8b71804da4f9352b6ab55e2973e09ceb875ec9fe64dc990940ed50e138ab859f8e902ecb3c2540c63e0ea9561cd95e7803584b2f3d6e2bda3b19e87
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # CHANGELOG
2
+
3
+ ## 1.2.0
4
+
5
+ From @BenMorganIO
6
+
7
+ - Added `center` tag.
8
+ - You are no longer required to set `wrapper(class: 'wrapper')` anymore. It is now simply: `wrapper`.
9
+ - The `wrapper` method is backwards compatible if options are provided.
10
+
11
+ ## 1.1.1
12
+
13
+ From @BenMorganIO
14
+
15
+ - Content from `layout` is now HTML safe.
16
+ - `layout` can now be provided `nil` content.
17
+
18
+ ## 1.1.0
19
+
20
+ From @BenMorganIO
21
+
22
+ - Added `layout` method with options to include styles into the head.
23
+
24
+ ## 1.0.0
25
+
26
+ Initial release
data/README.md CHANGED
@@ -97,15 +97,15 @@ The grid in Blot matches Ink very well. It is able to produce rows, sub-grids, c
97
97
  ```ruby
98
98
  container do
99
99
  row do
100
- wrapper(class: 'wrapper last') do
100
+ wrapper(class: 'last') do
101
101
  columns(:twelve, class: 'panel') { '.twelve.columns' }
102
102
  end
103
103
  end
104
104
  row do
105
- wrapper(class: 'wrapper') do
105
+ wrapper do
106
106
  columns(:six, class: 'panel') { '.six.columns' }
107
107
  end
108
- wrapper(class: 'wrapper last') do
108
+ wrapper(class: 'last') do
109
109
  columns(:six, class: 'panel') { '.six.columns' }
110
110
  end
111
111
  end
@@ -166,10 +166,34 @@ end
166
166
 
167
167
  ```ruby
168
168
  row do
169
- wrapper(class: 'wrapper') do
169
+ center do
170
+ 'Content'
171
+ end
172
+ end
173
+ ```
174
+
175
+ ```html
176
+ <table class="row">
177
+ <tr>
178
+ <td align="center" class="center">
179
+ <center>
180
+
181
+ Content
182
+
183
+ </center>
184
+ </td>
185
+ </tr>
186
+ </table>
187
+ ```
188
+
189
+ #### Render Centered Content from Columns
190
+
191
+ ```ruby
192
+ row do
193
+ wrapper do
170
194
  columns(:six, class: 'center panel') { 'Centered content' }
171
195
  end
172
- wrapper(class: 'wrapper last') do
196
+ wrapper(class: 'last') do
173
197
  columns(:six, class: 'center panel') do
174
198
  image_tag 'http://placehold.it/125x125&text=Centered%20Image', class: 'center', alt: 'centered image'
175
199
  end
@@ -212,7 +236,7 @@ end
212
236
 
213
237
  ```ruby
214
238
  row do
215
- wrapper(class: 'wrapper offset-by-four') do
239
+ wrapper(class: 'offset-by-four') do
216
240
  columns(:eight, class: 'panel') { 'Offset Content' }
217
241
  end
218
242
  end
@@ -239,13 +263,13 @@ end
239
263
 
240
264
  ```ruby
241
265
  row do
242
- wrapper(class: 'wrapper') do
266
+ wrapper do
243
267
  columns(:four, class: 'left-text-pad') { 'Text' }
244
268
  end
245
- wrapper(class: 'wrapper') do
269
+ wrapper do
246
270
  columns(:four) { 'Text' }
247
271
  end
248
- wrapper(class: 'wrapper last') do
272
+ wrapper(class: 'last') do
249
273
  columns(:four, class: 'right-text-pad') { 'Text' }
250
274
  end
251
275
  end
@@ -292,7 +316,7 @@ end
292
316
 
293
317
  ```ruby
294
318
  row do
295
- wrapper(class: 'center', align: 'center') do
319
+ center do
296
320
  container(class: 'wrapper last') do
297
321
  columns(:twelve) { 'Content' }
298
322
  end
@@ -331,13 +355,13 @@ end
331
355
 
332
356
  ```ruby
333
357
  row do
334
- wrapper(class: 'wrapper') do
358
+ wrapper do
335
359
  columns(:eight, sub_columns: true) do
336
360
  sub_columns(:eight) { '.eight.sub-columns' } +
337
361
  sub_columns(:four, class: 'last') { '.four.sub-columns' }
338
362
  end
339
363
  end
340
- wrapper(class: 'wrapper last') do
364
+ wrapper(class: 'last') do
341
365
  columns(:four) { '.four.columns' }
342
366
  end
343
367
  end
@@ -376,8 +400,8 @@ end
376
400
  ```ruby
377
401
  container do
378
402
  block_grid(up: :two) do
379
- wrapper { 'Column #1' }
380
- wrapper { 'Column #2' }
403
+ content_tag(:td) { 'Column #1' }
404
+ content_tag(:td) { 'Column #2' }
381
405
  end
382
406
  end
383
407
  ```
@@ -403,10 +427,10 @@ end
403
427
 
404
428
  ```ruby
405
429
  row do
406
- wrapper(class: 'wrapper') do
430
+ wrapper do
407
431
  columns(:eight) { 'Main content' }
408
432
  end
409
- wrapper(class: 'wrapper last') do
433
+ wrapper(class: 'last') do
410
434
  columns(:four, class: 'panel') { 'Panel content' }
411
435
  end
412
436
  end
@@ -506,7 +530,7 @@ hide_for_small
506
530
 
507
531
  ```ruby
508
532
  row do
509
- wrapper(class: 'wrapper last') do
533
+ wrapper(class: 'last') do
510
534
  show_for_small do
511
535
  columns(:twelve, class: 'panel') { '.show-for-small' }
512
536
  end
@@ -13,7 +13,9 @@ module Blot
13
13
  def container(options={})
14
14
  content_tag :table, class: 'container' do
15
15
  content_tag :tr do
16
- wrapper(options) { yield if block_given? }
16
+ content_tag :td, options do
17
+ yield if block_given?
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -42,7 +44,9 @@ module Blot
42
44
  content = if options[:sub_columns]
43
45
  block_given? ? yield : nil
44
46
  elsif !options.empty? || block_given?
45
- wrapper(options) { yield if block_given? }
47
+ content_tag :td, options do
48
+ optional_content(options) { yield if block_given? }
49
+ end
46
50
  else
47
51
  nil
48
52
  end
@@ -55,16 +59,29 @@ module Blot
55
59
 
56
60
  def sub_columns(width, options={})
57
61
  options[:class] = "#{width} sub-columns #{options[:class]}".strip
58
- wrapper(options) { yield if block_given? }
62
+ content_tag :td, options do
63
+ optional_content(options) { yield if block_given? }
64
+ end
59
65
  end
60
66
  alias :sub_column :sub_columns
61
67
 
62
68
  def wrapper(options={}, &block)
69
+ unless options.delete(:wrapper).is_a?(FalseClass) || options[:class] && options[:class].split(' ').include?('wrapper')
70
+ options[:class] = "wrapper #{options[:class]}".squish
71
+ end
63
72
  content_tag :td, options do
64
73
  optional_content(options) { yield if block_given? }
65
74
  end
66
75
  end
67
76
 
77
+ def center(&block)
78
+ content_tag :td, class: 'center', align: 'center' do
79
+ content_tag :center do
80
+ yield if block_given?
81
+ end
82
+ end
83
+ end
84
+
68
85
  private
69
86
 
70
87
  def expander
data/lib/blot/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Blot
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -105,29 +105,57 @@ describe Blot::Helpers::Grid do
105
105
  end
106
106
 
107
107
  describe '.wrapper' do
108
- it 'can be empty' do
109
- expect(view.wrapper).to eql <<-HTML.compress
108
+ it 'can be empty by setting to false' do
109
+ expect(view.wrapper(wrapper: false)).to eql <<-HTML.compress
110
110
  <td></td>
111
111
  HTML
112
112
  end
113
113
 
114
114
  it 'can yield content' do
115
115
  expect(view.wrapper { "Content" }).to eql <<-HTML.compress
116
- <td>Content</td>
116
+ <td class="wrapper">Content</td>
117
117
  HTML
118
118
  end
119
119
 
120
120
  it 'can have a class' do
121
- expect(view.wrapper(class: 'wrapper') { 'Content' }).to eql <<-HTML.compress
122
- <td class="wrapper">Content</td>
121
+ expect(view.wrapper(class: 'last') { 'Content' }).to eql <<-HTML.compress
122
+ <td class="wrapper last">Content</td>
123
123
  HTML
124
124
  end
125
125
 
126
126
  it 'can have multiple classes' do
127
- expect(view.wrapper(class: 'wrapper last') { 'Content' }).to eql <<-HTML.compress
128
- <td class="wrapper last">Content</td>
127
+ expect(view.wrapper(class: 'my-wrapper last') { 'Content' }).to eql <<-HTML.compress
128
+ <td class="wrapper my-wrapper last">Content</td>
129
129
  HTML
130
130
  end
131
+
132
+ it 'can have wrapper as a class' do
133
+ expect(view.wrapper(class: 'wrapper')).to eql <<-HTML.compress
134
+ <td class="wrapper"></td>
135
+ HTML
136
+ end
137
+ end
138
+
139
+ describe '.center' do
140
+ it 'can be empty' do
141
+ expect(view.center).to eql <<-HTML.compress
142
+ <td align="center" class="center">
143
+ <center></center>
144
+ </td>
145
+ HTML
146
+ end
147
+
148
+ it 'can yield centered content' do
149
+ expect(view.center { 'Content' }).to eql <<-HTML.compress
150
+ <td align="center" class="center">
151
+ <center>Content</center>
152
+ </td>
153
+ HTML
154
+ end
155
+
156
+ it 'cannot have classes' do
157
+ expect { view.center(class: 'wrapper') }.to raise_error(ArgumentError)
158
+ end
131
159
  end
132
160
 
133
161
  context 'private' do
@@ -145,15 +173,15 @@ describe Blot::Helpers::Grid do
145
173
  it 'can render two rows, twelve and six by six' do
146
174
  example = view.container do
147
175
  view.row do
148
- view.wrapper(class: 'wrapper last') do
176
+ view.wrapper(class: 'last') do
149
177
  view.columns(:twelve, class: 'panel') { '.twelve.columns' }
150
178
  end
151
179
  end +
152
180
  view.row do
153
- view.wrapper(class: 'wrapper') do
181
+ view.wrapper do
154
182
  view.columns(:six, class: 'panel') { '.six.columns' }
155
183
  end +
156
- view.wrapper(class: 'wrapper last') do
184
+ view.wrapper(class: 'last') do
157
185
  view.columns(:six, class: 'panel') { '.six.columns' }
158
186
  end
159
187
  end
@@ -212,10 +240,10 @@ describe Blot::Helpers::Grid do
212
240
 
213
241
  it 'can render centered content' do
214
242
  example = view.row do
215
- view.wrapper(class: 'wrapper') do
243
+ view.wrapper do
216
244
  view.columns(:six, class: 'center panel') { 'Centered content' }
217
245
  end +
218
- view.wrapper(class: 'wrapper last') do
246
+ view.wrapper(class: 'last') do
219
247
  view.columns(:six, class: 'center panel') do
220
248
  image_tag 'http://placehold.it/125x125&text=Centered%20Image', class: 'center', alt: 'centered image'
221
249
  end
@@ -256,7 +284,7 @@ describe Blot::Helpers::Grid do
256
284
 
257
285
  it 'can render offset columns' do
258
286
  example = view.row do
259
- view.wrapper(class: 'wrapper offset-by-four') do
287
+ view.wrapper(class: 'offset-by-four last') do
260
288
  view.columns(:eight, class: 'panel') { 'Offset Content' }
261
289
  end
262
290
  end
@@ -264,7 +292,7 @@ describe Blot::Helpers::Grid do
264
292
  expect(example).to eql <<-HTML.compress
265
293
  <table class="row">
266
294
  <tr>
267
- <td class="wrapper offset-by-four">
295
+ <td class="wrapper offset-by-four last">
268
296
 
269
297
  <table class="eight columns">
270
298
  <tr>
@@ -281,13 +309,13 @@ describe Blot::Helpers::Grid do
281
309
 
282
310
  it 'can render text-padding' do
283
311
  example = view.row do
284
- view.wrapper(class: 'wrapper') do
312
+ view.wrapper do
285
313
  view.columns(:four, class: 'left-text-pad') { 'Text' }
286
314
  end +
287
- view.wrapper(class: 'wrapper') do
315
+ view.wrapper do
288
316
  view.columns(:four) { 'Text' }
289
317
  end +
290
- view.wrapper(class: 'wrapper last') do
318
+ view.wrapper(class: 'last') do
291
319
  view.columns(:four, class: 'right-text-pad') { 'Text' }
292
320
  end
293
321
  end
@@ -332,7 +360,7 @@ describe Blot::Helpers::Grid do
332
360
 
333
361
  it 'can render full-width rows' do
334
362
  example = view.row do
335
- view.wrapper(class: 'center', align: 'center') do
363
+ view.center do
336
364
  view.container(class: 'wrapper last') do
337
365
  view.columns(:twelve) { 'Content' }
338
366
  end
@@ -369,13 +397,13 @@ describe Blot::Helpers::Grid do
369
397
 
370
398
  it 'can render a sub-grid' do
371
399
  example = view.row do
372
- view.wrapper(class: 'wrapper') do
400
+ view.wrapper do
373
401
  view.columns(:eight, sub_columns: true) do
374
402
  view.sub_columns(:eight) { '.eight.sub-columns' } +
375
403
  view.sub_columns(:four, class: 'last') { '.four.sub-columns' }
376
404
  end
377
405
  end +
378
- view.wrapper(class: 'wrapper last') do
406
+ view.wrapper(class: 'last') do
379
407
  view.columns(:four) { '.four.columns' }
380
408
  end
381
409
  end
@@ -412,8 +440,8 @@ describe Blot::Helpers::Grid do
412
440
  it 'can render a block-grid' do
413
441
  example = view.container do
414
442
  view.block_grid(up: :two) do
415
- view.wrapper { 'Column #1' } +
416
- view.wrapper { 'Column #2' }
443
+ view.content_tag(:td) { 'Column #1' } +
444
+ view.content_tag(:td) { 'Column #2' }
417
445
  end
418
446
  end
419
447
 
@@ -437,10 +465,10 @@ describe Blot::Helpers::Grid do
437
465
 
438
466
  it 'can render a sidebar' do
439
467
  example = view.row do
440
- view.wrapper(class: 'wrapper') do
468
+ view.wrapper do
441
469
  view.columns(:eight) { 'Main content' }
442
470
  end +
443
- view.wrapper(class: 'wrapper last') do
471
+ view.wrapper(class: 'last') do
444
472
  view.columns(:four, class: 'panel') { 'Panel content' }
445
473
  end
446
474
  end
@@ -30,7 +30,7 @@ describe Blot::Helpers::Visibility do
30
30
  context 'example' do
31
31
  it 'can render visibility of columns in a row' do
32
32
  example = view.row do
33
- view.wrapper(class: 'wrapper last') do
33
+ view.wrapper(class: 'last') do
34
34
  view.show_for_small do
35
35
  view.columns(:twelve, class: 'panel') { '.show-for-small' }
36
36
  end +
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben A Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -119,6 +119,7 @@ extra_rdoc_files: []
119
119
  files:
120
120
  - ".gitignore"
121
121
  - ".rspec"
122
+ - CHANGELOG.md
122
123
  - Gemfile
123
124
  - LICENSE.txt
124
125
  - README.md