-
Notifications
You must be signed in to change notification settings - Fork 0
Merge develop into main #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1605fa8
Add migration page
rartino 66b757c
Convert docs to markdown; add reference to website template repo
rartino e35c5fa
Improve handling of links with and without extensions in static gener…
rartino 1eb951f
Resolve merge conflict with editing docs/index
rartino 1647e28
Fix migration guide example error
rartino 1a7ebd9
Harden publish link rewriting and remove no-op serve URL suffix option
rartino ef8be02
Fix publish URL suffix normalization, cache link route resolution, an…
rartino 066daec
Add compatibility-mode default link test and harden HTML tag parsing …
rartino 05a9001
Use attribute-level tag parsing for safe publish link rewriting
rartino b417d4e
Normalize source-suffix links during publish rewrite to prevent broke…
rartino b839771
Update docs/how_it_works.md to be more precise on slashes in URLs
rartino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| Migration: Legacy Templates to Jinja2 | ||
| ===================================== | ||
|
|
||
| This guide maps common legacy template patterns to their modern Jinja2 equivalents. | ||
|
|
||
| Overview | ||
| -------- | ||
|
|
||
| Legacy projects typically use ``.httkweb.html`` templates with formatter-style | ||
| constructs such as ``{name:repeat::...}``, ``{func:call:...}``, and conditional | ||
| specifiers. Modern projects should use ``.html.j2`` (or ``.jinja``/``.j2``) | ||
| with standard Jinja2 syntax. | ||
|
|
||
| Template file naming | ||
| -------------------- | ||
|
|
||
| Legacy | ||
| ^^^^^^ | ||
|
|
||
| - ``default.httkweb.html`` | ||
| - ``base_default.httkweb.html`` | ||
| - function fragments like ``search_result.httkweb.html`` | ||
|
|
||
| Modern | ||
| ^^^^^^ | ||
|
|
||
| - ``default.html.j2`` | ||
| - ``base_default.html.j2`` | ||
| - function fragments like ``search_result.html.j2`` | ||
|
|
||
| Variable access | ||
| --------------- | ||
|
|
||
| Legacy: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| {title} | ||
| {page.relurl} | ||
|
|
||
| Modern: | ||
|
|
||
| .. code-block:: jinja | ||
|
|
||
| {{ title }} | ||
| {{ page.relurl }} | ||
|
|
||
| Escaping behavior | ||
| ----------------- | ||
|
|
||
| Legacy templates often rely on formatter-level quote/unquoted controls. | ||
| In Jinja2, use autoescaping defaults and explicit ``|safe`` only when needed. | ||
|
|
||
| Legacy: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| {content} | ||
| {content:unquoted} | ||
|
|
||
| Modern: | ||
|
|
||
| .. code-block:: jinja | ||
|
|
||
| {{ content }} | ||
| {{ content|safe }} | ||
|
|
||
| Loops | ||
| ----- | ||
|
|
||
| Legacy ``repeat``: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| {menuitems:repeat:: | ||
| <li>{{item}}</li> | ||
| } | ||
|
|
||
| Modern Jinja2: | ||
|
|
||
| .. code-block:: jinja | ||
|
|
||
| {% for item in menuitems %} | ||
| <li>{{ item }}</li> | ||
| {% endfor %} | ||
|
|
||
| Conditionals | ||
| ------------ | ||
|
|
||
| Legacy conditionals are encoded in format specs (for example ``if`` / ``if-not``). | ||
| Use Jinja2 control blocks directly. | ||
|
|
||
| Legacy: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| {error_404_reason:if:Reason: {error_404_reason}} | ||
|
|
||
| Modern: | ||
|
|
||
| .. code-block:: jinja | ||
|
|
||
| {% if error_404_reason %} | ||
| Reason: {{ error_404_reason }} | ||
| {% endif %} | ||
|
|
||
| Function-style calls | ||
| -------------------- | ||
|
|
||
| Legacy ``call`` often appears around helper access: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| {{pages:call:{{item}}:title}} | ||
|
|
||
| Modern: | ||
|
|
||
| .. code-block:: jinja | ||
|
|
||
| {{ pages(item, 'title') }} | ||
|
|
||
| Indexing and attribute access | ||
| ----------------------------- | ||
|
|
||
| Legacy: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| {{item[id]}} | ||
| {{item[formula]}} | ||
|
|
||
| Modern: | ||
|
|
||
| .. code-block:: jinja | ||
|
|
||
| {{ item['id'] }} | ||
| {{ item['formula'] }} | ||
|
|
||
| Function fragments (metadata) | ||
| ----------------------------- | ||
|
|
||
| Legacy metadata often points to fragment names without modern suffixes. | ||
| Modern projects should use clear names and Jinja templates. | ||
|
|
||
| Legacy metadata: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| results-function: search:q:search_result | ||
|
|
||
| Modern metadata (same key format, modern template files): | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| results-function: search:q:search_result | ||
|
|
||
| and template file: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| templates/search_result.html.j2 | ||
|
|
||
| Metadata key casing and structure | ||
| --------------------------------- | ||
|
|
||
| Prefer lowercase keys in modern projects: | ||
|
|
||
| - ``template`` instead of ``Template`` | ||
| - ``base_template`` instead of ``Base_template`` | ||
| - ``title`` instead of ``Title`` | ||
|
|
||
| Both styles may work in compatibility contexts, but lowercase metadata avoids | ||
| surprises and keeps templates predictable. | ||
|
|
||
| Migration checklist | ||
| ------------------- | ||
|
|
||
| 1. Rename templates to ``.html.j2``. | ||
| 2. Replace legacy formatter expressions with Jinja2 syntax. | ||
| 3. Keep helper usage explicit: ``pages(...)``, ``first_value(...)``, ``listdir(...)``. | ||
| 4. Normalize metadata keys to lowercase. | ||
| 5. Run your site with ``compatibility_mode=False`` and verify output. | ||
|
|
||
| Tip | ||
| --- | ||
|
|
||
| If needed, migrate page-by-page: | ||
|
|
||
| - Keep legacy project operational in compatibility mode. | ||
| - Port one template at a time to Jinja2. | ||
| - Switch the site to current mode once templates and metadata are fully modernized. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.