Module: DsfrLinkHelper
- Defined in:
- app/helpers/dsfr_link_helper.rb
Constant Summary collapse
- ICON_POSITIONS =
%w(left right).freeze
- SIZES =
%w(sm md lg).freeze
Instance Method Summary collapse
-
#dsfr_link_to(name = nil, options = nil, extra_options = nil, &block) ⇒ Object
Allows generating a link via plain parameters or the block-style form, just like Rails’s link_to.
Instance Method Details
#dsfr_link_to(name = nil, options = nil, extra_options = nil, &block) ⇒ Object
Allows generating a link via plain parameters or the block-style form, just like Rails’s link_to. In addition, it accepts some custom options in extra_options
(or options if using block-style) specific to the DSFR :
-
icon_left
[String]: name of an icon to put on the left side -
icon_right
[String]: name of an icon to put on the right side -
size
[String]: one of the size available inSIZES
.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/dsfr_link_helper.rb', line 15 def dsfr_link_to(name = nil, = nil, = nil, &block) = if block_given? = .then { |opts| add_default_class(opts) } .then { |opts| add_icons(opts) } .then { |opts| add_size(opts) } if block_given? link_to(name, , &block) else link_to(name, , ) end end |