Module: I18nProofreading::TagHelper

Defined in:
lib/i18n_proofreading/tag_helper.rb

Overview

Lets a host place the widget explicitly (<%= i18n_proofreading_tag %> at the end of a layout) instead of relying on auto-injection. This lives under lib and is required before the engine registers its Action View load hook: a host initializer may load Action View before Rails sets up application autoloaders, when an app/helpers constant cannot be resolved yet.

Instance Method Summary collapse

Instance Method Details

#i18n_proofreading_tagObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/i18n_proofreading/tag_helper.rb', line 10

def i18n_proofreading_tag
  return ''.html_safe unless I18nProofreading.available?(request)

  Widget.snippet(
    endpoint: I18nProofreading.config.suggestions_endpoint,
    locale: I18n.locale,
    active: I18nProofreading::Marking.enabled?,
    nonce: (content_security_policy_nonce if respond_to?(:content_security_policy_nonce))
  ).html_safe
end