RELEASE: Quixote 3.2a1
Neil Schemenauer <[email protected]> Tue, 9 Jul 2019 14:56:25 -0600
| Newsgroups | gmane.comp.web.quixote.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I've just put up a new alpha release of Quixote. This version adds
some new and optional syntax for PTL files. The motivation of the
new syntax is to allow .ptl files to be parsed as a valid .py file.
That is useful if you use tools like flake8 or black.
Also, if you use a fancy IDE like PyCharm or VSCode, making PTL code
look like valid Python code is also helpful. In those tools, you
can set the .ptl extension to be treated the same as a .py file.
To mark functions as PTL templates, you can now use a special
decorator. E.g.
from quixote.ptl import ptl_html, ptl_plain
@ptl_plain
def foo():
f'This is a plain text template'
@ptl_html
def bar():
F'This is a HTML template'
Also note, there is an alternative spelling for h-strings (now
mis-named, I guess). If you use the uppercase F as the prefix, the
literal text becomes an htmltext instance. I.e. instead of
h-strings like in Quixote 3.1, you use uppercase f-strings. It is
not an especially pretty solution but I think it works okay in
practice.
There is a new tool to convert your .ptl files to the new syntax.
See tools/ptl_to_decorator.py. Note that the tool converts
h-strings and template function declarations but doesn't add the
import of the decorators.
This is an alpha release so it is possible that something could
change yet. If you have feedback, please send it to me.