funkybob / stencil

A minimalist template engine for Python3
MIT License
58 stars 8 forks source link

Syntax change survey #15

Closed funkybob closed 5 years ago

funkybob commented 7 years ago

Currently, because I reuse the Python tokeniser, I can't use '.' as the lookup separator in expressions (because of ambiguities with floats).

Currently I'm using ':' but this plays double role with filter expressions.

Looking https://docs.python.org/2.7/reference/lexical_analysis.html#delimiters can anyone see a better symbol for this role?

I've currently a version of the code using '/'... it's easy to change.

funkybob commented 5 years ago

If we expand the syntax to distinguish the different lookups, we can go back to using '.' for attr lookups.

Suggestion:

foo
foo.bar
foo['bar']
foo[bar.baz]
foo(bar, baz)
shuttle1987 commented 5 years ago

Given that I'm not really using any floats in my templates I would like the ability to look up with .

funkybob commented 5 years ago

I'm also proposing dropping the "flow / filter" concept, so instead of :

{{ foo:bar|prefix:"six" }}

you would write:

{{ prefix(foo.bar, 'six') }}