Sha256: 164ce62c65358d6e4edce786d68efece75e4b5cc250cc097a47cfa170e0b1386

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module PlatformosCheck
  module LanguageServer
    def self.partial_tag(tag)
      /
        \{%-?\s*#{tag}\s+'(?<partial>[^']*)'|
        \{%-?\s*#{tag}\s+"(?<partial>[^"]*)"|

        # in liquid tags the whole line is white space until the tag
        ^\s*#{tag}\s+'(?<partial>[^']*)'|
        ^\s*#{tag}\s+"(?<partial>[^"]*)"
      /mix
    end

    def self.partial_tag_with_result(tag)
      /
        \{%-?\s*#{tag}\s+(?<var>[\w]+)\s*=\s*'(?<partial>[^']*)'|
        \{%-?\s*#{tag}\s+(?<var>[\w]+)\s*=\s*"(?<partial>[^"]*)"|

        # in liquid tags the whole line is white space until the tag
        ^\s*#{tag}\s+(?<var>[\w]+)+\s*=\s*'(?<partial>[^']*)'|
        ^\s*#{tag}\s+(?<var>[\w]+)+\s*=\s*"(?<partial>[^"]*)"
      /mix
    end

    PARTIAL_RENDER = partial_tag('render')
    PARTIAL_INCLUDE = partial_tag('include')
    PARTIAL_INCLUDE_FORM = partial_tag('include_form')
    PARTIAL_FUNCTION = partial_tag_with_result('function')
    PARTIAL_GRAPHQL = partial_tag_with_result('graphql')
    PARTIAL_BACKGROUND = partial_tag_with_result('background')

    ASSET_INCLUDE = /
      \{\{-?\s*'(?<partial>[^']*)'\s*\|\s*asset_url|
      \{\{-?\s*"(?<partial>[^"]*)"\s*\|\s*asset_url|

      # in liquid tags the whole line is white space until the asset partial
      ^\s*(?:echo|assign[^=]*=)\s*'(?<partial>[^']*)'\s*\|\s*asset_url|
      ^\s*(?:echo|assign[^=]*=)\s*"(?<partial>[^"]*)"\s*\|\s*asset_url
    /mix
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
platformos-check-0.2.2 lib/platformos_check/language_server/constants.rb
platformos-check-0.2.1 lib/platformos_check/language_server/constants.rb
platformos-check-0.2.0 lib/platformos_check/language_server/constants.rb
platformos-check-0.1.0 lib/platformos_check/language_server/constants.rb