Skip to content

Commit b93ecb1

Browse files
committed
callable cards prefix and suffix
1 parent 9662e6d commit b93ecb1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/3.0/cards.md

+14
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ end
199199

200200
<Image src="/assets/img/dashboards/prefix-suffix.jpg" width="651" height="168" alt="Avo Prefix & suffix" />
201201

202+
<br>
203+
204+
<VersionReq version="3.13" /> `prefix` and `suffix` became callable options.
205+
206+
The blocks are executed using [`Avo::ExecutionContext`](execution-context). Within this blocks, you gain access to all attributes of [`Avo::ExecutionContext`](execution-context) along with the `parent`.
207+
208+
```ruby{3,4}
209+
class Avo::Cards::UsersMetric < Avo::Cards::MetricCard
210+
self.id = 'users_metric'
211+
self.prefix = -> { params[:prefix] || parent.prefix }
212+
self.suffix = -> { params[:suffix] || parent.suffix }
213+
end
214+
```
215+
202216
## Chartkick card
203217

204218
A picture is worth a thousand words. So maybe a chart a hundred? Who knows? But creating charts in Avo is very easy with the help of the [chartkick](https://github.com/ankane/chartkick) gem.

0 commit comments

Comments
 (0)