File tree Expand file tree Collapse file tree 4 files changed +110
-0
lines changed
app/concepts/matestack/ui/core/em Expand file tree Collapse file tree 4 files changed +110
-0
lines changed Original file line number Diff line number Diff line change
1
+ %em {@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 ::Em
2
+ class Em < Matestack ::Ui ::Core ::Component ::Static
3
+
4
+ end
5
+ end
Original file line number Diff line number Diff line change
1
+ # matestack core component: Em
2
+
3
+ Show [ specs] ( /spec/usage/components/em_spec.rb )
4
+
5
+ The HTML em 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 em tag should have.
13
+
14
+ #### # class (optional)
15
+ Expects a string with all classes the em tag should have.
16
+
17
+ ## Example 1: Yield a given block
18
+
19
+ ``` ruby
20
+ em id: " foo" , class : " bar" do
21
+ plain ' Emphasized text' # optional content
22
+ end
23
+ ```
24
+
25
+ returns
26
+
27
+ ``` html
28
+ <em id =" foo" class =" bar" >Emphasized text</small >
29
+ ```
30
+
31
+ ## Example 2: Render options[ : text ] param
32
+
33
+ ``` ruby
34
+ em id: " foo" , class : " bar" , text: ' Emphasized text'
35
+ ```
36
+
37
+ returns
38
+
39
+ ``` html
40
+ <em id =" foo" class =" bar" >Emphasized text</small >
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../support/utils'
4
+ include Utils
5
+
6
+ describe 'Em Component' , type : :feature , js : true do
7
+ it 'Example 1 - yield, no options[:text]' do
8
+ class ExamplePage < Matestack ::Ui ::Page
9
+ def response
10
+ components do
11
+ # simple em tag
12
+ em do
13
+ plain 'Emphasized text'
14
+ end
15
+
16
+ # enhanced em tag
17
+ em id : 'my-id' , class : 'my-class' do
18
+ plain 'Enhanced emphasized text'
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ visit '/example'
25
+
26
+ static_output = page . html
27
+
28
+ expected_static_output = <<~HTML
29
+ < em > Emphasized text</ em >
30
+ < em id ="my-id " class ="my-class "> Enhanced emphasized text</ em >
31
+ HTML
32
+
33
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
34
+ end
35
+
36
+ it 'Example 2 - render options[:text]' do
37
+ class ExamplePage < Matestack ::Ui ::Page
38
+ def response
39
+ components do
40
+ # simple em
41
+ em text : 'Emphasized text'
42
+
43
+ # enhanced em
44
+ em id : 'my-id' , class : 'my-class' , text : 'Enhanced emphasized text'
45
+ end
46
+ end
47
+ end
48
+
49
+ visit '/example'
50
+
51
+ static_output = page . html
52
+
53
+ expected_static_output = <<~HTML
54
+ < em > Emphasized text</ em >
55
+ < em id ="my-id " class ="my-class "> Enhanced emphasized text</ em >
56
+ HTML
57
+
58
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
59
+ end
60
+ end
You can’t perform that action at this time.
0 commit comments