Method: Comparison::Presenter#inline_style
- Defined in:
- lib/comparison/presenter.rb
#inline_style ⇒ Object Also known as: style
Returns the I18n translation for ‘comparison.style`.
Use these translations to specify inline CSS style rules to be used when formatting comparison data. For example:
en:
comparison:
inline_style:
positive: 'color: #3c763d; background-color: #dff0d8;'
negative: 'color: #a94442; background-color: #f2dede;'
nochange: 'color: #777777;'
content_tag :span, cmp.difference, style: cmp.inline_style
# => "<span style=\"color: #3c763d; background-color: #dff0d8;\">+10%</span>"
In general, it’s probably preferable to use ‘#dom_classes` in conjunction with CSS style rules defined separate CSS files, but this isn’t always possible.
188 189 190 191 |
# File 'lib/comparison/presenter.rb', line 188 def inline_style key, *deprecated_keys = (%w[inline_style style css]) t key, default: [*deprecated_keys, ''] end |