- Install
liquid-validator
:sudo gem install liquid-validator
- Put the contents of the liquid file you want to try in a file called
liquid_to_test.liquid
. - Put the
test_liquid.rb
file in the same folder. - From that folder, run
ruby test_liquid.rb
in the terminal
Last active
January 10, 2018 17:46
-
-
Save ridem/0da7d8211cc38f1d4794fc23910c17f5 to your computer and use it in GitHub Desktop.
Test a Liquid file's syntax
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
{% if product.title == 'Awesome Shoes' %} | |
These shoes are awesome! | |
{% endif %} |
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
require 'liquid-validator' | |
template = File.open("liquid_to_test.liquid", "rb").read | |
validator = LiquidValidator::Validator.new(template) | |
if validator.valid? | |
puts "All fine!" | |
else | |
puts validator.errors.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment