Module: Livechat::WidgetHelper
- Defined in:
- lib/livechat/widget_helper.rb
Overview
Included into the host's ActionView. Kept under lib and required before the engine registers its Action View load hook: a host initializer may load Action View before Rails sets up application autoloaders, when a helper living only under app/helpers is not yet a resolvable constant.
Instance Method Summary collapse
-
#livechat_button(label = nil, message: nil, **options) ⇒ Object
A plain, unstyled
- #livechat_tag ⇒ Object
Instance Method Details
#livechat_button(label = nil, message: nil, **options) ⇒ Object
A plain, unstyled
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/livechat/widget_helper.rb', line 23 def (label = nil, message: nil, **) return unless Livechat.enabled?(request) label ||= .delete(:label) label ||= I18n.t(:launcher, scope: :livechat, default: 'Chat with us') data = (.delete(:data) { {} } || {}).merge(livechat_open: '') data[:livechat_message] = if .present? tag.(label, type: 'button', data:, **) end |
#livechat_tag ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/livechat/widget_helper.rb', line 9 def livechat_tag return unless Livechat.enabled?(request) Widget.snippet( locale: I18n.locale, authenticated: livechat_visitor.present?, avatar_url: livechat_avatar_url, nonce: (content_security_policy_nonce if respond_to?(:content_security_policy_nonce)) ).html_safe end |