Module: DocsKit::Controller
- Defined in:
- lib/docs_kit/controller.rb
Overview
Controller glue for a docs site. Include in ApplicationController to get the one shared render helper.
class ApplicationController < ActionController::Base
include DocsKit::Controller
def show = render_page(Views::Landings::Show.new)
end
Instance Method Summary collapse
-
#render_page(view) ⇒ Object
Render a Phlex page that is itself a full HTML document (it composes Docs::Shell, which emits /
/).
Instance Method Details
#render_page(view) ⇒ Object
Render a Phlex page that is itself a full HTML document (it composes Docs::Shell, which emits /
/).layout: false prevents the
Rails ERB application layout from double-nesting . phlex-rails still
renders through a real view context, so CSRF, dom_id, url helpers, and the
phlex-reactive token signer all work inside components.
A .md/.text request instead returns the page's Markdown twin, derived
from the SAME render (DocsKit::MarkdownExport walks the rendered HTML). So
GET /docs/x.md is faithful GFM of exactly what /docs/x shows — the
author writes nothing extra, and the two never drift.
22 23 24 25 26 |
# File 'lib/docs_kit/controller.rb', line 22 def render_page(view) return render_markdown(view) if markdown_request? render view, layout: false end |