File tree Expand file tree Collapse file tree 4 files changed +119
-0
lines changed
app/concepts/matestack/ui/core/address Expand file tree Collapse file tree 4 files changed +119
-0
lines changed Original file line number Diff line number Diff line change
1
+ %address {@tag_attributes}
2
+ - if options[:text].nil? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
Original file line number Diff line number Diff line change
1
+ module Matestack ::Ui ::Core ::Address
2
+ class Address < Matestack ::Ui ::Core ::Component ::Static
3
+
4
+ end
5
+ end
Original file line number Diff line number Diff line change
1
+ # matestack core component: Address
2
+
3
+ Show [ specs] ( ../../spec/usage/components/address_spec.rb )
4
+
5
+ The HTML ` <address> ` tag implemented in ruby.
6
+
7
+ ## Parameters
8
+
9
+ This component can take 2 optional configuration params and either yield content or display what gets passed to the ` text ` configuration param.
10
+
11
+ #### # id (optional)
12
+ Expects a string with all ids the address should have.
13
+
14
+ #### # class (optional)
15
+ Expects a string with all classes the address should have.
16
+
17
+ ## Example 1 - yield a given block
18
+
19
+ ``` ruby
20
+ address do
21
+ plain ' Codey McCodeface'
22
+ br
23
+ plain ' 1 Developer Avenue'
24
+ br
25
+ plain ' Techville'
26
+ end
27
+ ```
28
+
29
+ returns
30
+
31
+ ``` html
32
+ <address >
33
+ Codey McCodeface<br >
34
+ 1 Developer Avenue<br >
35
+ Techville
36
+ </address >
37
+ ```
38
+
39
+ ## Example 2 - render options[ : text ] param
40
+
41
+ ``` ruby
42
+ address text: ' PO Box 12345'
43
+ ```
44
+
45
+ returns
46
+
47
+ ``` html
48
+ <address >
49
+ PO Box 12345
50
+ </address >
51
+ ```
Original file line number Diff line number Diff line change
1
+ require_relative '../../support/utils'
2
+ include Utils
3
+
4
+ describe 'Address Component' , type : :feature , js : true do
5
+
6
+ it 'Example 1 - yield a given block' do
7
+
8
+ class ExamplePage < Matestack ::Ui ::Page
9
+
10
+ def response
11
+ components {
12
+ address do
13
+ plain 'Codey McCodeface'
14
+ br
15
+ plain '1 Developer Avenue'
16
+ br
17
+ plain 'Techville'
18
+ end
19
+ }
20
+ end
21
+
22
+ end
23
+
24
+ visit '/example'
25
+
26
+ static_output = page . html
27
+
28
+ expected_static_output = <<~HTML
29
+ < address > Codey McCodeface< br > 1 Developer Avenue< br > Techville</ address >
30
+ HTML
31
+
32
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
33
+ end
34
+
35
+ it 'Example 2 - render options[:text] param' do
36
+
37
+ class ExamplePage < Matestack ::Ui ::Page
38
+
39
+ def response
40
+ components {
41
+ address text : 'PO Box 12345'
42
+ }
43
+ end
44
+
45
+ end
46
+
47
+ visit '/example'
48
+
49
+ static_output = page . html
50
+
51
+ expected_static_output = <<~HTML
52
+ < address > PO Box 12345</ address >
53
+ HTML
54
+
55
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
56
+ end
57
+
58
+ end
You can’t perform that action at this time.
0 commit comments