Repository navigation
feat(server): navigation and block checks for Liquid templates - #253
Merged
Merged
Conversation
Liquid had highlighting only. For 1.0 it gets what ERB, Haml and Slim
have: go to definition, links, hover and completion for render,
include and include_relative (Jekyll's _includes under _config.yml,
otherwise the liquid gem's _name.liquid next to the file), and errors
for unclosed {{ and {%, unclosed or stray block tags and mismatched
end tags, also in `ruby-templates check`. Liquid is no longer marked
experimental, and rubyTemplates.liquid.disabledDiagnostics switches
the new rules off in the editor.
Closes #98
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
Review found valid templates reported as broken: a lone `{%` inside
raw, raw inside comment, `{% doc %}` bodies and Jekyll front matter
were read as tags. Verbatim blocks now take their end tag as Liquid
does, comments honour raw, doc is verbatim and front matter is
skipped. A Shopify theme's renders resolve to snippets/, include names
with `..` resolve to nothing as in Jekyll, completion skips hidden and
dependency folders, `_config.yaml`/`.toml` mark a Jekyll site, and
`_name.liquid` wins over `_name.html.liquid` as in the gem.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #98. Phases 2 and 3, so Liquid ships as a full language in 1.0. It is no longer marked experimental, and the Stability page covers it.
Navigation
Go to Definition, document links, hover and completion work for
{% render %},{% include %}and{% include_relative %}, with quoted names, Jekyll's unquoted names and{%-. Names are resolved in this order:_includes/<name>under the nearest_config.yml,_config.yamlor_config.toml.include_relativeis relative to the file. Names with..resolve to nothing, as in Jekyll.snippets/<name>.liquidunder the nearest folder that hassnippets/pluslayout/orconfig/settings_schema.json._<name>.liquidnext to the file, then_<name>.html.liquid.Completion skips hidden folders,
node_modules,_siteandvendor. Rails behaviour stays gated off for Liquid documents.Checks
Four errors, also reported by
ruby-templates check:Syntax/LiquidUnclosedTag: a{{or{%that is never closed.Syntax/LiquidUnclosedBlock: a block tag without its end tag.Syntax/LiquidStrayEndTag: an end tag with no open block.Syntax/LiquidMismatchedEndTag: an end tag for a different block.What is read and what isn't:
if,unless,for,case,capture,tablerow,form,paginate,highlight, pluscomment,rawanddoc.{% x %}…{% endx %}tags are ignored.raw,commentanddocare not read as tags, the way the liquid gem treats them, includingrawinsidecomment.{% liquid %}statements are checked.rubyTemplates.liquid.disabledDiagnosticsswitches these rules off in the editor.Not done: refs inside
{% liquid %}and inside multi-line tags, and checking thatelse/whensit in the right block.Tests
liquid.rsunit tests: refs and prefixes; Jekyll, Shopify and gem resolution on temp dirs;..refused; completion filters; balanced and unbalanced blocks; the verbatim cases from review (lone{%in raw, raw in comment, doc, front matter);{% liquid %}statements;test/broken/bad.html.liquidviainclude_str!.test/e2e.js: render →_card.liquid; Jekyll include; Shopify snippet render and completion; links, hover and completion; a diagnostic with its code; the Rails gate case kept.test/cli.js: a broken.liquidfile exits 1 with its code.test:server,e2e,cli,test:rules,test:tokens,test:unit,format:check,buildandtest:vscode(first round) pass.Generated by Claude Code