-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce :rigid parsing mode
#1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
beaea6f
Introduce :rigid parsing mode
karreiro 69a807e
Add rigid_parse_with_error_context and clarifications
charlespwd 06279ec
Add a rigid_parse method to `cycle`
charlespwd 22232cc
Add rigid_parse to `render`
charlespwd 40928e1
Add rigid_parse method to `include`
charlespwd 8f5361b
Add `ExpressionParser` and `ExpressionConsumer`
karreiro 7527f8a
Use `ExpressionParser` in the `ParseContext` when parsing in `:rigid`…
karreiro d9caf26
Remove `ExpressionParser` in favor of `ParseContext#safe_parse`
karreiro 5625f6f
Fix cycle tag
karreiro 42fcbcc
Fix an int the `cycle` tag, add extra unit tests, and updated parser …
karreiro 0d7a7a5
Fail with trailing elements in the `cycle` tag
karreiro 8e6faa4
Add rigid_parse to `case/when`
karreiro a16b955
Remove unnecessary skips
karreiro c36852d
Use safe_parse_expression instead of parse_expression
karreiro 533396b
Make it possible to safe_parse subsets of expressions
charlespwd 1308b97
Stricter 1:1 refactor of strict_parse for Variable
charlespwd 5718f8b
rigid set_attribute in for parsing
charlespwd 1ba6fab
No longer test `ParseContext` directly on `RigidModeUnitTest` as
karreiro fd81ac1
Remove redundant tests where rigid and strict modes have the same
karreiro 376d849
Add rigid parser to `tablerow` tag
karreiro 1c3c979
render end of string is not optional
charlespwd bc32531
Fix alias parsing
charlespwd 26f092b
Fixup include parsing of with expression
charlespwd fd186dc
Fixup cycle rigid parsing to be backwards compatible
charlespwd 937b733
Fix assert_template_result tests not picking up Liquid::Environment.d…
charlespwd 82428de
* Update `bin/render` script to present an error when no template is …
karreiro e4bf43e
Update infrastructure that handles parsing switching:
karreiro f0ed8e5
Fix variable to keep it backward-compatible in strict mode
karreiro 0946c4b
Covered changes with more tests, remove redundant cases, and the new …
karreiro 44dfa39
Update `History.md`
karreiro 195fd5a
Update `History.md` (5.8.8 -> 5.9.0)
karreiro 54b41db
Update Rakefile
karreiro 36ec055
Update test/unit/tags/case_tag_unit_test.rb
karreiro 8c8a843
Update test/integration/tags/render_tag_test.rb
karreiro ba5fb99
Rename `with_error_mode(...)` to `with_error_modes(...)`
karreiro 1e684d4
Add rigid mode to `rake benchmark` task
karreiro 0064198
Simplify render/include tags following PR review feedback
karreiro d6c8892
Extract `/\w+:0x\h{8}/` regex to `UNNAMED_CYCLE_PATTERN` constant
karreiro 0916f9a
Update README.md
karreiro 438ac4f
Update test/integration/tags/table_row_test.rb
karreiro 462a8b2
Add unit test mixing positional and kwargs arguments
karreiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
|
karreiro marked this conversation as resolved.
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env ruby | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'bundler/setup' | ||
| require 'liquid' | ||
|
|
||
| class VirtualFileSystem | ||
| def initialize | ||
| snippet_1 = <<~LIQUID | ||
| <h1> | ||
| {{- greating | default: 'Hello' }}, {{ name | default: 'world' -}}! | ||
| </h1> | ||
| LIQUID | ||
| snippet_2 = <<~LIQUID | ||
| {%- for i in (1..5) -%} | ||
| > {{ i }} | ||
| {%- endfor -%} | ||
| LIQUID | ||
|
|
||
| @templates = { | ||
| 'snippet-1' => snippet_1, | ||
| 'snippet-2' => snippet_2, | ||
| } | ||
| end | ||
|
|
||
| def read_template_file(key) | ||
| @templates[key] || raise(Liquid::FileSystemError, "No such template '#{key}'") | ||
| end | ||
| end | ||
|
|
||
| def source | ||
| File.read(ARGV[0]) | ||
| rescue StandardError | ||
| 'Usage: bin/render example/server/templates/index.liquid' | ||
| end | ||
|
|
||
| def assigns | ||
| { | ||
| 'date' => Time.now, | ||
| } | ||
| end | ||
|
|
||
| puts Liquid::Template | ||
| .parse(source, error_mode: :rigid) | ||
| .tap { |t| t.registers[:file_system] = VirtualFileSystem.new } | ||
| .render(assigns) |
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.