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