File tree Expand file tree Collapse file tree 5 files changed +104
-2
lines changed
app/concepts/matestack/ui/core/q Expand file tree Collapse file tree 5 files changed +104
-2
lines changed Original file line number Diff line number Diff line change
1
+ %q {@tag_attributes}
2
+ - if block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
Original file line number Diff line number Diff line change
1
+ module Matestack ::Ui ::Core ::Q
2
+ class Q < Matestack ::Ui ::Core ::Component ::Static
3
+
4
+ def setup
5
+ @tag_attributes . merge! ( {
6
+ "cite" : options [ :cite ]
7
+ } )
8
+ end
9
+
10
+ end
11
+ end
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ The HTML blockquote tag implemented in ruby.
9
9
This component can take 3 optional configuration params and either yield content or display what gets passed to the ` text ` configuration param.
10
10
11
11
#### # id (optional)
12
- Expects a string with all ids the span should have.
12
+ Expects a string with all ids the blockquote should have.
13
13
14
14
#### # class (optional)
15
- Expects a string with all classes the span should have.
15
+ Expects a string with all classes the blockquote should have.
16
16
17
17
#### # cite (optional)
18
18
Expects a string referencing a cite for the blockquote.
Original file line number Diff line number Diff line change
1
+ # matestack core component: Q
2
+
3
+ Show [ specs] ( ../../spec/usage/components/q_spec.rb )
4
+
5
+ The HTML q tag implemented in ruby.
6
+
7
+ ## Parameters
8
+
9
+ This component can take 4 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 quote should have.
13
+
14
+ #### # class (optional)
15
+ Expects a string with all classes the quote should have.
16
+
17
+ #### # text (optional)
18
+ Expects a string with the text that should go into the ` <q> ` tag.
19
+
20
+ #### # cite (optional)
21
+ Expects a string for referencing the source for the quote.
22
+
23
+ ## Example 1: Yield a given block
24
+
25
+ ``` ruby
26
+ q id: " foo" , class : " bar" do
27
+ plain ' Hello World' # optional content
28
+ end
29
+ ```
30
+
31
+ returns
32
+
33
+ ``` html
34
+ <q id =" foo" class =" bar" >
35
+ Hello World
36
+ </q >
37
+ ```
38
+
39
+ ## Example 2: Render options[ : text ] param
40
+
41
+ ``` ruby
42
+ q id: " foo" , class : " bar" , cite: " helloworld.io" text: ' Hello World'
43
+ ```
44
+
45
+ returns
46
+
47
+ ``` html
48
+ <q id =" foo" class =" bar" cite =" helloworld.io" >
49
+ Hello World
50
+ </q >
Original file line number Diff line number Diff line change
1
+ require_relative "../../support/utils"
2
+ include Utils
3
+
4
+ describe "Q Component" , type : :feature , js : true do
5
+
6
+ it "Example 1" do
7
+
8
+ class ExamplePage < Matestack ::Ui ::Page
9
+
10
+ def response
11
+ components {
12
+ #simple q
13
+ q text : "A simple quote"
14
+
15
+ # enhanced q
16
+ q id : 'my-id' , class : 'my-class' , cite : 'www.matestack.org/example' do
17
+ plain 'This is a enhanced q with text'
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
+ < q > A simple quote</ q >
30
+ < q cite ="www.matestack.org/example " id ="my-id " class ="my-class "> This is a enhanced q with text</ q >
31
+ HTML
32
+
33
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
34
+ end
35
+
36
+ end
You can’t perform that action at this time.
0 commit comments