module Rodauth::Rails::Feature::Render
Public Class Methods
included(feature)
click to toggle source
# File lib/rodauth/rails/feature/render.rb, line 5 def self.included(feature) feature.auth_methods :rails_render end
Public Instance Methods
render(page)
click to toggle source
Renders templates without layout. First tries to render a user-defined template or partial, otherwise falls back to Rodauth's template.
Calls superclass method
# File lib/rodauth/rails/feature/render.rb, line 18 def render(page) rails_render(partial: page.tr("-", "_"), layout: false) || rails_render(action: page.tr("-", "_"), layout: false) || super.html_safe end
view(page, *)
click to toggle source
Renders templates with layout. First tries to render a user-defined template, otherwise falls back to Rodauth's template.
Calls superclass method
# File lib/rodauth/rails/feature/render.rb, line 11 def view(page, *) rails_render(action: page.tr("-", "_"), layout: true) || rails_render(html: super.html_safe, layout: true) end
Private Instance Methods
_rails_controller_instance()
click to toggle source
Only look up template formats that the current request is accepting.
Calls superclass method
# File lib/rodauth/rails/feature/render.rb, line 40 def _rails_controller_instance controller = super controller.formats = rails_request.formats.map(&:ref).compact controller end
rails_render(*args)
click to toggle source
Calls the Rails
renderer, returning nil if a template is missing.
# File lib/rodauth/rails/feature/render.rb, line 31 def rails_render(*args) return if rails_api_controller? rails_controller_instance.render_to_string(*args) rescue ActionView::MissingTemplate nil end