Sha256: 94b751ef4e6e93e78d1cf99b3ca41894abb760650ccdad0c8572c33276e618d6

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 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

2 entries across 2 versions & 1 rubygems

Version Path
platformos-check-0.0.3 lib/platformos_check/language_server/constants.rb
platformos-check-0.0.2 lib/platformos_check/language_server/constants.rb