Skip to content

Calls and test/filter arity errors render leniently where Jinja2 raises TypeError #90

Description

@Nuhiat-Arefin

Malformed expressions render in ginger where Jinja2 raises a TypeError.

Reproduction

template Jinja2 ginger
{{[1()]}} TypeError: 'int' object is not callable empty (ok)
{{ attr is divisibleby }} TypeError: test_divisibleby() missing 1 required positional argument: 'num' empty (ok)
{{ o is sameas }} TypeError: test_sameas() missing 1 required positional argument: 'other' empty (ok)

Calls on other non-callables ('tuple' object is not callable), builtin tests called with extra arguments, and len/round on scalars behave the same way.

Root cause

Calls on non-callable values return null, and builtin tests and filters evaluate with missing or wrongly typed arguments instead of raising an error (the builtin dispatch in src/Text/Ginger/Run.hs and src/Text/Ginger/Run/Builtins.hs applied to GVal values).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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