File tree Expand file tree Collapse file tree 4 files changed +48
-5
lines changed
app/concepts/matestack/ui/core/span Expand file tree Collapse file tree 4 files changed +48
-5
lines changed Original file line number Diff line number Diff line change 1
1
PATH
2
2
remote: .
3
3
specs:
4
- matestack-ui-core (0.6 .0 )
4
+ matestack-ui-core (0.7 .0 )
5
5
cells-haml
6
6
cells-rails
7
7
haml
Original file line number Diff line number Diff line change 1
1
%span {@tag_attributes}
2
- - if block_given?
2
+ - if options[:text].nil? && block_given?
3
3
= yield
4
+ - else
5
+ = options[:text]
Original file line number Diff line number Diff line change @@ -6,15 +6,15 @@ The HTML span tag implemented in ruby.
6
6
7
7
## Parameters
8
8
9
- This component can take 2 optional configuration params and optional content.
9
+ This component can take 2 optional configuration params and either yield content or display what gets passed to the ` text ` configuration param .
10
10
11
11
#### # id (optional)
12
12
Expects a string with all ids the span should have.
13
13
14
14
#### # class (optional)
15
15
Expects a string with all classes the span should have.
16
16
17
- ## Example
17
+ ## Example 1: Yield a given block
18
18
19
19
``` ruby
20
20
span id: " foo" , class : " bar" do
@@ -29,3 +29,16 @@ returns
29
29
Hello World
30
30
</span >
31
31
```
32
+
33
+ ## Example 2: Render options[ : text ] param
34
+
35
+ ``` ruby
36
+ span id: " foo" , class : " bar" , text: ' Hello World'
37
+ ```
38
+
39
+ returns
40
+
41
+ ``` html
42
+ <span id =" foo" class =" bar" >
43
+ Hello World
44
+ </span >
Original file line number Diff line number Diff line change 3
3
4
4
describe 'Span Component' , type : :feature , js : true do
5
5
6
- it 'Example 1' do
6
+ it 'Example 1 - yield, no options[:text] ' do
7
7
8
8
class ExamplePage < Matestack ::Ui ::Page
9
9
@@ -35,4 +35,32 @@ def response
35
35
expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
36
36
end
37
37
38
+ it 'Example 2 - render options[:text]' do
39
+
40
+ class ExamplePage < Matestack ::Ui ::Page
41
+
42
+ def response
43
+ components {
44
+ # simple span
45
+ span text : 'I am simple'
46
+
47
+ # enhanced span
48
+ span id : 'my-id' , class : 'my-class' , text : 'I am enhanced'
49
+ }
50
+ end
51
+
52
+ end
53
+
54
+ visit '/example'
55
+
56
+ static_output = page . html
57
+
58
+ expected_static_output = <<~HTML
59
+ < span > I am simple</ span >
60
+ < span id ="my-id " class ="my-class "> I am enhanced</ span >
61
+ HTML
62
+
63
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
64
+ end
65
+
38
66
end
You can’t perform that action at this time.
0 commit comments