Module: Katalyst::GOVUK::FormBuilder::Frontend

Defined in:
app/helpers/katalyst/govuk/form_builder/frontend.rb

Instance Method Summary collapse

Instance Method Details

#govuk_formbuilder_initObject

Marks the page as JS-capable and enhances govuk-frontend components, on load and as the DOM changes (Turbo morphs, lazily-loaded frames, stream inserts). Render at the end of ; on a Turbo replace render the snippet re-executes with the new body, and everything it sets up is scoped to the body element it ran against. rubocop:disable Rails/OutputSafety



13
14
15
16
17
18
19
20
# File 'app/helpers/katalyst/govuk/form_builder/frontend.rb', line 13

def govuk_formbuilder_init
  tag.script type: "module", nonce: request.content_security_policy_nonce do
    <<~JS.html_safe
      import {initAll} from "@katalyst/govuk-formbuilder";
      initAll(#{govuk_formbuilder_init_options});
    JS
  end
end