-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Jinja filter to get relative paths (#39)
Useful in templates to avoid using absolute paths (`/`) which then don't work if the website is in a subdirectory of the domain. Add the `relative_to` filter directly to our Jinja environments and use it in the documentation to test.
- Loading branch information
Showing
4 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{# Define some macros to automate things #} | ||
|
||
{%- macro page_link(id, site) -%} | ||
{# Create a link to a page with the text being its title #} | ||
{%- set page = site[id] -%} | ||
<a href="/{{ page.path }}">{{ page.title }}</a> | ||
{%- macro page_link(id, site, page) -%} | ||
{# Create a relative link to a page with the text being its title #} | ||
{%- set target = site[id] -%} | ||
<a href="{{ target.path|relative_to(page.path) }}">{{ target.title }}</a> | ||
{%- endmacro -%} |
This file contains 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 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