Sha256: 202116ace51bc2a39fb9d919ca239778df54d2d112c2eaa26984936f9a8aa276

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

# frozen_string_literal: true

module Liquid
  # Break tag to be used to break out of a for loop.
  #
  # == Basic Usage:
  #    {% for item in collection %}
  #      {% if item.condition %}
  #        {% break %}
  #      {% endif %}
  #    {% endfor %}
  #
  # @liquid_public_docs
  # @liquid_type tag
  # @liquid_category iteration
  # @liquid_name break
  # @liquid_summary
  #   Stops a [`for` loop](/docs/api/liquid/tags/for) from iterating.
  # @liquid_syntax
  #   {% break %}
  class Break < Tag
    INTERRUPT = BreakInterrupt.new.freeze

    def render_to_output_buffer(context, output)
      context.push_interrupt(INTERRUPT)
      output
    end
  end

  Template.register_tag('break', Break)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
liquid-5.5.1 lib/liquid/tags/break.rb
liquid-5.5.0 lib/liquid/tags/break.rb