File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1
- %a {"@click.prevent": "perform", "href": action_path}
1
+ %a {@tag_attributes, "@click.prevent": "perform", "href": action_path}
2
2
- if block_given?
3
3
= yield
Original file line number Diff line number Diff line change @@ -85,6 +85,34 @@ failure: {
85
85
}
86
86
```
87
87
88
+ ### ID (optional)
89
+
90
+ This parameter accepts a string of ids that the action component should have:
91
+
92
+ ``` ruby
93
+ id: ' my-action-id'
94
+ ```
95
+
96
+ which renders as an HTML ` id ` attribute, like so:
97
+
98
+ ``` html
99
+ <a id =" my-action-id" >...</a >
100
+ ```
101
+
102
+ ### Class (optional)
103
+
104
+ This parameter accepts a string of classes that the action component should have:
105
+
106
+ ``` ruby
107
+ class : ' my-action-class'
108
+ ```
109
+
110
+ which renders as an HTML ` class ` attribute, like so:
111
+
112
+ ``` html
113
+ <a class =" my-action-class" >...</a >
114
+ ```
115
+
88
116
### Notify
89
117
90
118
Not in use right now.
Original file line number Diff line number Diff line change @@ -386,6 +386,33 @@ def page2
386
386
387
387
end
388
388
389
+ it 'accepts class and id attributes and returns them as the corresponding HTML attributes' do
390
+
391
+ class ExamplePage < Page ::Cell ::Page
392
+
393
+ def response
394
+ components {
395
+ action action_config do
396
+ button text : "Click me!"
397
+ end
398
+ }
399
+ end
400
+
401
+ def action_config
402
+ return {
403
+ id : 'action-id' ,
404
+ class : 'action-class'
405
+ }
406
+ end
407
+
408
+ end
409
+
410
+ visit "/example"
411
+
412
+ expect ( page ) . to have_css ( 'a#action-id.action-class' )
413
+
414
+ end
415
+
389
416
it 'action_path: passing path as a string (not recommended)' do
390
417
391
418
Rails . application . routes . append do
You can’t perform that action at this time.
0 commit comments