This section describes the controller helpers provided by MarkdownRecord to help interact with MarkdownRecord.
To use controller helpers in a controller, simply include the MarkdownRecord::ControllerHelpers
module like so:
include ::MarkdownRecord::ControllerHelpers
When the module is included, you will be able to call the following methods in your controller:
content_fragment
: finds a content fragment based on a passed id. If no id is passed it looks for params[:content_path]
instead.render_html
: takes an optional content fragment and an optional layout, then renders the fragment as HTML. If no fragment is provided, it calls content_fragment
to get it using params[:content_path]
. If no layout is provided, it uses the public_layout configured for MarkdownRecord (by default this is the application layout).render_json
: takes an optional content fragment and renders it as JSON. If no fragment is provided, it calls content_fragment
to get it using params[:content_path]
.download_html
: same a render_html
but renders a file for download.download_json
: same a render_json
but renders a file for download.The above content was rendered from source files at: content/v_0_1/controller_helpers