Module: LexxyVariables::Helper

Defined in:
lib/lexxy_variables/helper.rb

Overview

Editor-side view helpers. LexxyVariables::Engine includes this module into Action View when the host app boots, so lexxy_variables_prompt and lexxy_variable_chip are callable from any view with no setup. context is opaque to the gem and is passed straight through to the host's catalog.

Instance Method Summary collapse

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).



17
18
19
20
21
# File 'lib/lexxy_variables/helper.rb', line 17

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 the editor extension reads, built from the configured catalog. context is passed to the catalog callable.



9
10
11
12
13
# File 'lib/lexxy_variables/helper.rb', line 9

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