Module: InertiaRails::Helper
- Defined in:
- lib/inertia_rails/helper.rb
Instance Method Summary collapse
- #inertia_headers ⇒ Object
- #inertia_meta_tags ⇒ Object
- #inertia_page ⇒ Object
- #inertia_rendering? ⇒ Boolean
- #inertia_root(id: nil, page: inertia_page) ⇒ Object
- #inertia_ssr_head ⇒ Object
Instance Method Details
#inertia_headers ⇒ Object
11 12 13 14 15 16 |
# File 'lib/inertia_rails/helper.rb', line 11 def inertia_headers InertiaRails.deprecator.warn( '`inertia_headers` is deprecated and will be removed in InertiaRails 4.0, use `inertia_ssr_head` instead.' ) inertia_ssr_head end |
#inertia_meta_tags ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/inertia_rails/helper.rb', line 26 def = (inertia_page || {}).dig(:props, :_inertia_meta) || [] = .map do || .to_tag(tag) end safe_join(, "\n") end |
#inertia_page ⇒ Object
22 23 24 |
# File 'lib/inertia_rails/helper.rb', line 22 def inertia_page controller.instance_variable_get('@_inertia_page') end |
#inertia_rendering? ⇒ Boolean
18 19 20 |
# File 'lib/inertia_rails/helper.rb', line 18 def inertia_rendering? controller.instance_variable_get('@_inertia_rendering') end |
#inertia_root(id: nil, page: inertia_page) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/inertia_rails/helper.rb', line 36 def inertia_root(id: nil, page: inertia_page) config = controller.send(:inertia_configuration) id ||= config.root_dom_id if config.use_script_element_for_initial_page safe_join([ tag.script(page.to_json.html_safe, 'data-page': id, type: 'application/json'), tag.div(id: id) ], "\n") else tag.div(id: id, 'data-page': page.to_json) end end |
#inertia_ssr_head ⇒ Object
7 8 9 |
# File 'lib/inertia_rails/helper.rb', line 7 def inertia_ssr_head controller.instance_variable_get('@_inertia_ssr_head') end |