- Notifications
You must be signed in to change notification settings - Fork1
A test suite for the Liquid template language.
License
jg-rp/golden-liquid
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A test suite forLiquid, the safe, customer-facing template language for flexible web apps.
The tests defined ingolden_liquid.json attempt to cover the syntax and behavior of allstandard tags and filters. This is a work in progress and will lag behind changes toShopify/Liquid.
To use this test suite, it's recommended you embed this repository as a gitsubmodule of your repository.
For our purposes "standard" Liquid is the one describedhere withShopify/Liquid being the reference implementation. Not to be confused with the extended variation of Liquid used for Shopify stores.
All tests pass with Shopify/liquid Ruby 3. If you have Ruby installed, you can run the test suite against the reference implementation by cloning this repository and running the following commands from the project root.
bundle installbundle exec rake
golden_liquid.json
looks like this:
{"description":"Golden Liquid test suite","tests": [ {"name":"identifiers, ascii lowercase","template":"{% assign foo = 'hello' %}{{ foo }} {{ bar }}","data": {"bar":"goodbye" },"tags": ["strict" ],"result":"hello goodbye" },... ]}
Individual test files andgolden_liquid.json
are validated againstgolden_liquid.schema.json
. Each object in thetests
array can include the following fields.
name
- A descriptive name that uniquely identifies the test.template
- Liquid source text as a string.data
- A JSON object mapping strings to arbitrary, possibly nested, strings, numbers, arrays, objects and booleans. These are the variables that the associated template should be rendered with.result
- The expected result of rendering the template with the associated context data.results
- An array of possible expected results from rendering the template with the given context data.templates
- A JSON object mapping strings to strings. You can think of it as a mock file system for testing{% include %}
and{% render %}
.invalid
- A Boolean indicating if the test case should raise/throw an exception/error.tags
- An optional array of strings used to categorize the test case.
Tags are used to categorize test cases. This allows consumers of this test suite to easily exclude or target entire categories of tests, or enable/disable features in certain cases.
strict
- Indicates that the test case should be parsed and rendered in strict mode, if a strict mode is available.absent
- Indicates that the test cases is asserting the absence of a feature. For example, the absence of a logicalnot
operator.utc
- The test case assumes the host timezone is set to UTC
Pull requests to add or update tags are welcome.
Thebenchmark_fixtures
folder contains Liquid templates and data useful for benchmarking Liquid engines. For each folder inbenchmark_fixtures
, the convention is thatdata.json
contains render context data, andtemplates/index.liquid
is the "base" template that might include/render other templates in thetemplates
folder.
Pull requests for more benchmark fixtures are welcome.
SeeCONTRIBUTING.md.
About
A test suite for the Liquid template language.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Uh oh!
There was an error while loading.Please reload this page.