Module: LexxyVariables::Helper
- Defined in:
- lib/lexxy_variables/helper.rb
Overview
Mixed into Action View by the engine. context is opaque to the gem and is
passed straight through to the host's catalog/assigns/resolve callables.
Instance Method Summary collapse
-
#lexxy_variable_chip(name, key:, block: false) ⇒ Object
Default variable/attachment chip shown in the editor.
-
#lexxy_variables_prompt(context: nil, trigger: "{{", empty_results: "No variables found") ⇒ Object
Renders the
the editor extension reads, built from the configured catalog. - #render_lexxy_content(rich_text, context: nil, locale: I18n.locale) ⇒ Object
Instance Method Details
#lexxy_variable_chip(name, key:, block: false) ⇒ Object
Default variable/attachment chip shown in the editor. block: renders the
block style, for chips that expand to a rich fragment (e.g. snippets).
19 20 21 22 23 |
# File 'lib/lexxy_variables/helper.rb', line 19 def lexxy_variable_chip(name, key:, block: false) tag.span name, class: [ "lexxy-variable", ("lexxy-variable--block" if block) ], data: { lexxy_key: key } end |
#lexxy_variables_prompt(context: nil, trigger: "{{", empty_results: "No variables found") ⇒ Object
Renders the context is passed to the catalog callable.
11 12 13 14 15 |
# File 'lib/lexxy_variables/helper.rb', line 11 def lexxy_variables_prompt(context: nil, trigger: "{{", empty_results: "No variables found") items = Array(LexxyVariables.config.resolve_catalog(context)) render partial: "lexxy_variables/prompt", locals: { items: items, trigger: trigger, empty_results: empty_results } end |
#render_lexxy_content(rich_text, context: nil, locale: I18n.locale) ⇒ Object
5 6 7 |
# File 'lib/lexxy_variables/helper.rb', line 5 def render_lexxy_content(rich_text, context: nil, locale: I18n.locale) LexxyVariables::Pipeline.new(self).call(rich_text, context: context, locale: locale) end |