Skip to content

Warn on dot-notation assign instead of erroring #129

@osteele

Description

@osteele

Summary

Change gojekyll to accept {% assign page.property = value %} syntax with a warning instead of failing the build. This improves compatibility with Ruby Jekyll, which silently accepts this syntax.

Background

Testing with Ruby Jekyll 4.4.1 confirms that {% assign page.custom_var = "from-assign" %} is parsed without error but is effectively a no-op:

Expression Ruby Jekyll Output
{{ page.custom_var }} after {% assign page.custom_var = "from-assign" %} from-frontmatter (assign did NOT override)
{{ page.new_var }} after {% assign page.new_var = "new-value" %} (empty) (assign did NOT make it accessible)

The assign creates a variable under the literal key "page.custom_var" in the assigns hash, but {{ page.custom_var }} resolves via the page drop (page.custom_var), a different lookup path.

Currently gojekyll errors: syntax error: dot notation in assign tag requires Jekyll extensions to be enabled. This breaks compatibility with Jekyll sites that use this syntax (see #60).

Proposed behavior

  • Default mode: Accept the syntax, emit a warning: "{% assign page.custom_var = ... %} has no effect. In Jekyll, dot notation in assign creates an inaccessible variable."
  • Future strict mode (--strict): Upgrade warnings to errors

Dependencies

Depends on osteele/liquid#144 — adding warnings support to liquid's render output. Once liquid can return warnings alongside rendered output, gojekyll can:

  1. Collect warnings from all page renders
  2. Print them to stderr
  3. Optionally fail the build in strict mode

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions