Class: Webhookdb::Liquid::Expose

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/webhookdb/liquid/expose.rb

Overview

Allow customers to expose variables from a template using custom blocks and registers. See github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tag-blocks for more info about blocks. See github.com/Shopify/liquid/wiki/Liquid-for-Programmers#difference-between-assigns-and-registers for info about “registers”, which are used as template-render-specific mutable state (so we can mutate it in the tag/block, then inspect the mutated value after-the-fact).

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, var_name, options) ⇒ Expose

Returns a new instance of Expose.



15
16
17
18
# File 'lib/webhookdb/liquid/expose.rb', line 15

def initialize(tag_name, var_name, options)
  super
  @var_name = var_name.strip.to_sym
end

Instance Method Details

#render(context) ⇒ Object



20
21
22
23
24
# File 'lib/webhookdb/liquid/expose.rb', line 20

def render(context)
  content = super
  context.registers[@var_name] = content
  ""
end