chunks | ||
expressions | ||
filters | ||
generics | ||
tags | ||
.gitignore | ||
.travis.yml | ||
engine.go | ||
LICENSE | ||
liquid_test.go | ||
Makefile | ||
README.md | ||
template.go | ||
test.html |
Go Liquid Template Parser
goliquid
is a pure Go implementation of Shopify Liquid templates, for use in gojekyll.
Status
- Basics
- Literals
- String Escapes
- Variables
- Operators (partial)
- Arrays
- Whitespace Control
- Literals
- Tags
- Comment
- Control Flow
if
/else
/elsif
unless
case
when
else
- Iteration
- modifiers (
limit
,reversed
,offset
) range
break
,continue
- loop variables
tablerow
cycle
- modifiers (
- Raw
- Variables
- Assign
- Capture
- Filters
sort_natural
,uniq
,escape
,truncatewords
,url_decode
,url_encode
- everything else
Install
go get -u github.com/osteele/goliquid
Contribute
Setup
make setup
Install Ragel. On macOS: brew install ragel
.
Workflow
go generate ./...
go test ./...
Test just the scanner:
cd expressions
ragel -Z scanner.rl && go test
Preview the documentation:
godoc -http=:6060&
open http://localhost:6060/pkg/github.com/osteele/liquid/
References
https://shopify.github.io/liquid
https://help.shopify.com/themes/liquid
https://github.com/Shopify/liquid/wiki/Liquid-for-Designers
Attribution
Package | Author | Description |
---|---|---|
github.com/leekchan/timeutil | Kyoung-chan Lee | formatting dates |
gopkg.in/yaml.v2 | Canonical | YAML support |
Ragel | Adrian Thurston | scanning expressions |
Michael Hamrah's Lexing with Ragel and Parsing with Yacc using Go was essential to understanding go yacc
.
The original Liquid engine, of course, for the design and documentation of the Liquid template language. Many of the tag and filter test cases are taken directly from the Liquid documentation.
(That said, this is a clean-room implementation to make sure it just implements the documented design.)
Other Implementations
Go:
- https://godoc.org/github.com/karlseguin/liquid is a partial implementation.
- https://godoc.org/github.com/acstech/liquid is a more active fork of Karl Seguin's implementation.
- https://godoc.org/github.com/hownowstephen/go-liquid is a more recent entry.
https://github.com/Shopify/liquid/wiki/Ports-of-Liquid-to-other-environments lists ports to other languages.
License
MIT License