A tool to rewrite parts of template files (DTML, ZPT).
Project description
gocept.template_rewrite
A tool to rewrite parts of template files (DTML, ZPT and XPT).
The initial use case is to have a pluggable system to convert Python 2 expressions in templates to Python 3.
This package runs on Python 3.6 up to 3.10.
Requirements
For the rewrite to work properly, it is necessary to have this structure attr="value" for attributes in tags with no whitespaces around the =, as otherwise the values will get lost.
Caveats
During rewrite double hyphens within HTML-comments are removed as the Chameleon engine in Zope 4 (and the actual specification) is very strict about it.
The underlying lib2to3 does not take into account, that the cmp function is no longer available in Python 3.
This tool converts Python 2 to Python 3 - that means the code may not be compatible with Python 2 any more. For these edge cases manual changes are required to make it compatible with both versions.
Developing gocept.template_rewrite
- Author:
- Issues:
- Source code:
- Current change log:
https://raw.githubusercontent.com/gocept/gocept.template_rewrite/master/CHANGES.rst
- Installation:
pip3 install gocept.template_rewrite
- Run the tests:
$ tox
Change log for gocept.template_rewrite
1.1 (2022-04-29)
Convert single quotes used for HTML attributes into double quotes. (#25)
Add support for Python 3.9 and 3.10.
Ensure compatibility with pytest >= 6.0.
Use GHA as CI system.
1.0 (2020-04-07)
Print exact location of error in case of problems parsing Page Templates.
Add parameter –collect-errors that continues to parse all given files and prints all found parsing errors but exits with an error and does not replace any files if an error was found. This replaces the argument –only-show-errors present in earlier versions. This allows to create a full list of errors to be fixed before a rewrite is possible.
Add notes about more caveats.
File discovery now also includes TrustedFSPageTemplate files, which are registered with the file ending .xpt.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gocept.template_rewrite-1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb391cb5765a5098dc642307edba4e96a48b3a0551e21ee33702431c07892d6 |
|
MD5 | a7041932257ffa32c6dc28a3ca136735 |
|
BLAKE2b-256 | 577e0a2fd227fdec617820f2a00baee17b49448495a9d3be67468dfebe449777 |
Hashes for gocept.template_rewrite-1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68e29fca05f2a115b8299889c06298484334964f550d9f1304f6f67a1b7ec671 |
|
MD5 | 1dc738bdfedbfc891d09f2779f48a28e |
|
BLAKE2b-256 | 955b4e7e6014c74e0589cf663084627828182671ff0a1a36f1125eaeb6616d06 |