diff --git a/lib/liquid/tags/case.rb b/lib/liquid/tags/case.rb index d6ab64e6..fe9f6637 100644 --- a/lib/liquid/tags/case.rb +++ b/lib/liquid/tags/case.rb @@ -1,6 +1,19 @@ # frozen_string_literal: true +# @public_docs module Liquid + # @public_docs + # @title Case + # @syntax The syntax + # @summary The summary + # @type tag + # @description + # Creates a switch statement to execute a particular block of code when a variable has a specified value. + # `case`` initializes the switch statement, and `when`` statements define the various conditions. + # + # An optional `else`` statement at the end of the case provides code to execute if none of the conditions are met. + +An optional else statement at the end of the case provides code to execute if none of the conditions are met. class Case < Block Syntax = /(#{QuotedFragment})/o WhenSyntax = /(#{QuotedFragment})(?:(?:\s+or\s+|\s*\,\s*)(#{QuotedFragment}.*))?/om diff --git a/lib/liquid/tags/if.rb b/lib/liquid/tags/if.rb index f4b57d7d..a71990ad 100644 --- a/lib/liquid/tags/if.rb +++ b/lib/liquid/tags/if.rb @@ -1,16 +1,22 @@ # frozen_string_literal: true +# @public_docs module Liquid - # If is the conditional block + # @public_docs + # @title If + # @syntax The syntax + # @summary Executes a block of code only if a certain condition is `true`. + # @type tag + # @description + # If is the conditional block # - # {% if user.admin %} - # Admin user! - # {% else %} - # Not admin user - # {% endif %} - # - # There are {% if count < 5 %} less {% else %} more {% endif %} items than you need. + # {% if user.admin %} + # Admin user! + # {% else %} + # Not admin user + # {% endif %} # + # There are {% if count < 5 %} less {% else %} more {% endif %} items than you need. class If < Block Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/o ExpressionsAndOperators = /(?:\b(?:\s?and\s?|\s?or\s?)\b|(?:\s*(?!\b(?:\s?and\s?|\s?or\s?)\b)(?:#{QuotedFragment}|\S+)\s*)+)/o diff --git a/lib/liquid/tags/unless.rb b/lib/liquid/tags/unless.rb index db725dbf..17aa02ec 100644 --- a/lib/liquid/tags/unless.rb +++ b/lib/liquid/tags/unless.rb @@ -2,11 +2,17 @@ require_relative 'if' +# @public_docs module Liquid - # Unless is a conditional just like 'if' but works on the inverse logic. - # - # {% unless x < 0 %} x is greater than zero {% endunless %} + # @public_docs + # @title Unless + # @syntax The syntax + # @summary The opposite of `if`` – executes a block of code only if a certain condition is not met. + # @type tag + # @description + # Unless is a conditional just like 'if' but works on the inverse logic. # + # {% unless x < 0 %} x is greater than zero {% endunless %} class Unless < If def render_to_output_buffer(context, output) # First condition is interpreted backwards ( if not )