Class: ActiveMail::Components::Cta
- Extended by:
- T::Sig
- Defined in:
- lib/activemail/components/cta.rb
Overview
Colors read from tokens at transform time (runtime config), not load-time constants. Styles are inlined so the button survives clients that strip <style> (Gmail mobile…).
Constant Summary
Constants inherited from Base
Base::BUTTON_PADDING, Base::IGNORED_ON_PASSTHROUGH, Base::TABLE_RESET
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from ActiveMail::Components::Base
Instance Method Details
#transform(node, inner) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/activemail/components/cta.rb', line 14 def transform(node, inner) # A CTA without a link is an authoring bug — surface it at render time. raise ArgumentError, '<cta> requires an href attribute' if node.attr('href').to_s.strip.empty? style = ActiveMail.tokens.(class?(node, 'secondary') ? :secondary : :primary) anchor = %(<a href="#{escape_attr(node.attr('href'))}"#{target_attribute(node)} ) + %(style="#{link_style(style)}">#{inner}</a>) ( outer_classes: combine_classes(node, 'cta'), inner: anchor, cell_style: cell_style(style) ) end |