Module: PonkotsuMdEditor::Helpers
- Defined in:
- lib/ponkotsu/md/editor/helpers.rb
Overview
Helper methods for rendering Markdown editor components in Rails views This module provides view helpers that can be used in ERB templates to integrate the PonkotsuMdEditor functionality
Instance Method Summary collapse
-
#markdown_editor(form, attribute, content, options = {}) ⇒ String
Renders a Markdown editor component for the given form and attribute.
Instance Method Details
#markdown_editor(form, attribute, content, options = {}) ⇒ String
Renders a Markdown editor component for the given form and attribute.
Example usage in a Rails view:
<%= markdown_editor(f, :content, {
lang: :en,
preview: true,
tools: [:bold, :italic, :strikethrough],
placeholder: "This is Placeholder."
}) %>
26 27 28 29 30 31 32 33 |
# File 'lib/ponkotsu/md/editor/helpers.rb', line 26 def markdown_editor(form, attribute, content, = {}) form = form[:form] if form.is_a?(Hash) attribute = attribute[:attribute] if attribute.is_a?(Hash) content = content[:attribute] if content.is_a?(Hash) = [:options] if .is_a?(Hash) render "ponkotsu_md_editor/editor", locals: { attribute: attribute, content: content, form: form, options: } end |