Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
- name: Install dependencies
run: make deps

- name: Install tools
run: make tools

- name: Build
run: make build

Expand Down Expand Up @@ -104,19 +101,16 @@ jobs:
with:
go-version: 1.26.x

- name: Install tools
run: make tools
- name: Install Ragel
run: sudo apt-get update && sudo apt-get install --yes ragel

- name: Regenerate yacc parser
run: |
cd expressions
goyacc expressions.y
gofmt -w y.go
- name: Regenerate generated files
run: make generate

- name: Check for differences
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Generated parser files are out of date. Please run 'go generate ./...' and commit the results."
echo "Generated files are out of date. Please run 'make generate' and commit the results."
git diff
exit 1
fi
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.output
*.out
/.gocache/
/liquid
*.test
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@

## Unreleased

### Added

- **Named Filter Arguments** (#42): Added keyword arguments for filters, including `allow_false` support in the `default` filter.
- **String Literal Escapes** (#45): Added `\\`, `\"`, `\n`, `\t`, and `\r` escapes in double-quoted string literals. Single-quoted strings remain literal.
- **Shopify Filters** (#146): Added `where`, `sum`, `at_least`, `at_most`, `pluralize`, `handleize`/`handle`, `remove_last`, and `replace_last`.

### Fixed

- **32-bit Platform Build**: Fixed build failure on 32-bit platforms (ARM, x86) where `math.MaxInt64` overflowed `uint` in the `isIntegerType` comparison. The `uint` value is now widened to `uint64` before comparing.
- **Optional Nil Arguments**: Fixed explicit `nil` values in optional filter arguments and distinguished them from omitted arguments in `where`.

### CI

- Added 32-bit build verification (linux/arm, linux/386) to CI pipeline.
- Pinned Go development tools in `go.mod`, aligned local and CI lint versions, and added reproducibility checks for both generated expression-parser files.

## 1.8.1 (2026-02-27)

Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Fork and clone the repo.
Install package dependencies and development tools:

```bash
make tools # Install code generation tools
make tools # Download the versions pinned in go.mod
make deps # Download Go dependencies
```

[Install golangci-lint](https://golangci-lint.run/usage/install/#local-installation).
On macOS: `brew install golangci-lint`
The lint target runs the golangci-lint version pinned in `go.mod`; a separate
global installation is not required.

#### Set up Git Hooks (Recommended)

Expand Down Expand Up @@ -128,7 +128,7 @@ open http://localhost:6060/pkg/github.com/osteele/liquid/

To work on the lexer, install Ragel. On macOS: `brew install ragel`.

The parser and lexer tools are installed via `make tools`, which installs:
The Go code-generation tools are pinned in `go.mod` and downloaded by `make tools`:
- `goyacc` for parser generation
- `stringer` for string method generation

Expand Down
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ PACKAGES := $(shell $(GOCMD) list ./... | grep -v /vendor/)
COVERAGE_FILE := coverage.out
COVERAGE_HTML := coverage.html

# Tools - installed via tools.go or go.mod tool directive
TOOLS_DIR := $(shell $(GOCMD) env GOPATH)/bin
GOYACC := $(TOOLS_DIR)/goyacc
STRINGER := $(TOOLS_DIR)/stringer
GOLANGCI_LINT := $(GOCMD) tool golangci-lint # Use version from go.mod
# Tools managed by the go.mod tool directive
GOYACC := $(GOCMD) tool goyacc
STRINGER := $(GOCMD) tool stringer
GOLANGCI_LINT := $(GOCMD) tool golangci-lint

# Colors for output
RED := \033[0;31m
Expand Down Expand Up @@ -61,7 +60,7 @@ clean: ## Remove build artifacts and temporary files
##@ Code Generation

.PHONY: generate
generate: tools ## Generate code (parsers, string methods, etc.)
generate: tools check-ragel ## Generate code (parsers, string methods, etc.)
@echo "Generating code..."
$(GOGENERATE) ./...

Expand Down Expand Up @@ -150,14 +149,15 @@ mod-verify: ## Verify dependencies
##@ Tools

.PHONY: tools
tools: ## Install development tools
@echo "Installing development tools..."
@$(GOCMD) install golang.org/x/tools/cmd/goyacc@latest
@$(GOCMD) install golang.org/x/tools/cmd/stringer@latest
@echo "${GREEN}✓ Tools installed${NC}"
@echo ""
@echo "${YELLOW}Note: golangci-lint is managed via go.mod tool directive${NC}"
@echo "Run 'go tool golangci-lint' to use it"
tools: ## Download pinned Go development tools
@echo "Downloading pinned Go development tools..."
@$(GOYACC) -h >/dev/null 2>&1
@$(STRINGER) -h >/dev/null 2>&1
@echo "${GREEN}✓ Go tools available${NC}"

.PHONY: check-ragel
check-ragel: ## Verify that the Ragel state-machine compiler is installed
@command -v ragel >/dev/null || (echo "${RED}Ragel is required for code generation${NC}" && exit 1)

.PHONY: install-hooks
install-hooks: ## Install pre-commit hooks
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ This section provides a comprehensive guide to using and extending the Liquid te

These features of Shopify Liquid aren't implemented:

- Filter keyword parameters, for example `{{ image | img_url: '580x', scale: 2
}}`. [[Issue #42](https://github.com/osteele/liquid/issues/42)]
- Warn and lax [error modes](https://github.com/shopify/liquid#error-modes).
- Note: `Engine.LaxFilters()` enables Shopify-compatible behavior for undefined filters (silently pass through).

Expand Down Expand Up @@ -382,11 +380,11 @@ and filter test cases are taken directly from the Liquid documentation.

MIT License

[go-url]: https://github.com/osteele/liquid/actions?query=workflow%3A%22Build+Status%22
[go-svg]: https://github.com/osteele/liquid/actions/workflows/go.yml/badge.svg
[go-url]: https://github.com/osteele/liquid/actions/workflows/test.yml
[go-svg]: https://github.com/osteele/liquid/actions/workflows/test.yml/badge.svg

[golangci-lint-url]: https://github.com/osteele/liquid/actions?query=workflow%3Lint
[golangci-lint-svg]: https://github.com/osteele/liquid/actions/workflows/golangci-lint.yml/badge.svg
[golangci-lint-url]: https://github.com/osteele/liquid/actions/workflows/lint.yml
[golangci-lint-svg]: https://github.com/osteele/liquid/actions/workflows/lint.yml/badge.svg

[godoc-url]: https://godoc.org/github.com/osteele/liquid
[godoc-svg]: https://godoc.org/github.com/osteele/liquid?status.svg
Expand Down
6 changes: 3 additions & 3 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ func BenchmarkEngine_Parse(b *testing.B) {

buf := new(bytes.Buffer)
for range 1000 {
_, err := io.WriteString(buf, `if{% if true %}true{% elsif %}elsif{% else %}else{% endif %}`)
_, err := io.WriteString(buf, `if{% if true %}true{% elsif false %}elsif{% else %}else{% endif %}`)
require.NoError(b, err)
_, err = io.WriteString(buf, `loop{% for item in array %}loop{% break %}{% endfor %}`)
require.NoError(b, err)
_, err = io.WriteString(buf, `case{% case value %}{% when a %}{% when b %{% endcase %}`)
_, err = io.WriteString(buf, `case{% case value %}{% when a %}{% when b %}{% endcase %}`)
require.NoError(b, err)
_, err = io.WriteString(buf, `expr{{ a and b }}{{ a add: b }}`)
_, err = io.WriteString(buf, `expr{{ a and b }}{{ a | plus: b }}`)
require.NoError(b, err)
}

Expand Down
4 changes: 2 additions & 2 deletions expressions/parser.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:generate ragel -Z scanner.rl
//go:generate sh -c "{ echo '// Code generated by ragel. DO NOT EDIT.'; cat scanner.go; } > scanner.go.tmp && mv scanner.go.tmp scanner.go"
//go:generate sh -c "{ echo '// Code generated by ragel. DO NOT EDIT.'; sed '/^\\/\\/line scanner.go:/d' scanner.go; } > scanner.go.tmp && mv scanner.go.tmp scanner.go"
//go:generate gofmt -w scanner.go
//go:generate goyacc expressions.y
//go:generate go tool goyacc expressions.y

package expressions

Expand Down
6 changes: 0 additions & 6 deletions expressions/scanner.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions expressions/y.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading