Sha256: e10be4627f47d3e2950186c30ffbdfbf9376c7237d2eb9d45933d43cd652f3b5

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

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

        # in liquid tags the whole line is white space until the tag
        ^\s*#{tag}#{'(_rc)?' if with_rc}\s+'(?<partial>[^']*)'|
        ^\s*#{tag}#{'(_rc)?' if with_rc}\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_THEME_RENDER = partial_tag('theme_render', with_rc: true)
    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

13 entries across 13 versions & 1 rubygems

Version Path
platformos-check-0.4.9 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.8 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.7 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.6 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.5 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.4 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.3 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.2 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.1 lib/platformos_check/language_server/constants.rb
platformos-check-0.4.0 lib/platformos_check/language_server/constants.rb
platformos-check-0.3.3 lib/platformos_check/language_server/constants.rb
platformos-check-0.3.1 lib/platformos_check/language_server/constants.rb
platformos-check-0.3.0 lib/platformos_check/language_server/constants.rb