Module: LexxyVariables::WithVariables

Defined in:
lib/lexxy_variables/with_variables.rb

Overview

Mixed into ActionText::Content via the :action_text_content load hook.

Instance Method Summary collapse

Instance Method Details

#with_variables(context: nil, locale: nil, assigns: {}, **inline_assigns) ⇒ Object

Returns a new ActionText::Content with every variable chip resolved, so Action Text's own conversions chain from the result:

@post.body.with_variables(first_name: "Ada").to_plain_text
@post.body.with_variables(context: tenant).to_s
@post.body.with_variables.to_markdown  # on Rails versions that ship it

Takes context:, locale:, and per-render values as keyword args or an assigns: hash.



13
14
15
16
17
# File 'lib/lexxy_variables/with_variables.rb', line 13

def with_variables(context: nil, locale: nil, assigns: {}, **inline_assigns)
  LexxyVariables::Resolver.new.call(
    self, context: context, locale: locale, assigns: assigns.merge(inline_assigns)
  )
end