app/models/concerns/templatable.rb
# Alters the current templating scope by adding the given object to it. All of the given object's properties (or at
# least those made available to its +Liquid::Drop+ object) can be accessed by liquid templates. Works in conjunction
# with {LiquidDroppable}. This scope alteration will be available through the runtime of the given block.
#
#   template_with({ subject: 'world' }) { template_object 'hello, {{ subject }}' } # => 'hello, world'
#
# @param object [nil, #to_liquid] the object that you wish to add to the current templating scope. Must respond to
#   #to_liquid and return a +Liquid::Drop+-like object to properly be added to the scope. If this is the case, its
#   properties will be made available to any liquid templates.
Alters the current templating scope by adding the given object to it. All of the given object's properties (or at
least those made available to its +Liquid::Drop+ object) can be accessed by liquid templates. Works in conjunction
with {LiquidDroppable}. This scope alteration will be available through the runtime of the given block.


Alters the current templating scope by adding the given object to it . All of the given object ' s properties ( or at least those made available to its + Liquid :: Drop + object ) can be accessed by liquid templates . Works in conjunction with { LiquidDroppable } . This scope alteration will be available through the runtime of the given block .
def template_with(object = nil)
    if object.nil?
      yield
    elsif !object.respond_to?(:to_liquid)
      Rails.logger.warn("#{object} could not be interpolated with Liquid")
      yield
    else
      object = normalize_hash(object)
      begin
        template_context.environments.unshift(object.to_liquid)
        yield
      ensure
        template_context.environments.shift
      end
    end
  end
def template_with ( object = nil ) if object . nil? yield elsif ! object . respond_to? ( :to_liquid ) Rails . logger . warn ( "#{object} could not be interpolated with Liquid" ) yield else object = normalize_hash ( object ) begin template_context . environments . unshift ( object . to_liquid ) yield ensure template_context . environments . shift end end end
Alters the current templating scope by adding the given object to it.
Alters the current templating scope by adding the given object to it .
object
the object that you wish to add to the current templating scope. Must respond to #to_liquid and return a +Liquid::Drop+-like object to properly be added to the scope. If this is the case, its properties will be made available to any liquid templates.
the object that you wish to add to the current templating scope . Must respond to #to_liquid and return a + Liquid :: Drop + - like object to properly be added to the scope . If this is the case its properties will be made available to any liquid templates .