Skip to content

Commit f5c5a04

Browse files
committed
Updated docs
1 parent fe2971e commit f5c5a04

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

docs/guides/pages.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,37 @@ Easily create static and dynamic pages with a layout.
77

88
## Dynamic pages
99

10-
Dynamic pages can use the following formats:
10+
Pages use the [jinjapy](https://github.com/hyperflask/jinjapy) file format. It combines python code and a [jinja template](#the-page-template). The python code will be executed first on every request, then the template will be rendered.
1111

12-
- **jpy**: jinjapy hybrid format that let you execute code before rendering the template
13-
- **py**: python code only
12+
The python code is enclosed inside 2 lines containing 3 dashes "---"
1413

15-
A jinjapy file contains 2 sections:
14+
A special [page object](#the-page-object) is available in the python code. Assign values to this object so that they become available in the template.
1615

17-
- Some Python code enclosed by lines containg 3 dashes "---"
18-
- A body containing some Jinja template code
16+
```jpy
17+
---
18+
page.message = "Hello world"
19+
---
20+
{{ message }}
21+
```
1922

20-
Both are optional:
23+
Both the python code or the templates are optional:
2124

2225
- If the python code is missing, the file only contains a Jinja template
2326
- If the python code is left unclosed (the file starts with "---" on a single line followed by some python code), the file has no template
2427

2528
The python code has a few global variables injected when executed: `page`, `request`, `abort`, `redirect`, `url_for`, `current_app`, `render_template`.
2629

30+
!!! tip
31+
Pages can also be declared using .py files. In this case they will be pure python modules. Use `page.respond()` to send a response.
32+
33+
## The page template
34+
35+
Templates are powered by [Jinja](https://jinja.palletsprojects.com/en/stable/).
36+
37+
We recommend reading the [Flask templating guide](https://flask.palletsprojects.com/en/stable/templating/).
38+
39+
Hyperflask includes built-ins UI components powered by [DaisyUI](https://daisyui.com/). Check out the [Components](/guides/components/#built-in-ui-components) guide.
40+
2741
## Content pages
2842

2943
No python code will be executed on content pages.
@@ -49,14 +63,6 @@ The URL rule is constructed using the following rules:
4963

5064
The placeholder value is available through the [`page` object](#the-page-object) (eg: `page.slug`).
5165

52-
## The page template
53-
54-
Templates are powered by [Jinja](https://jinja.palletsprojects.com/en/stable/).
55-
56-
We recommend reading the [Flask templating guide](https://flask.palletsprojects.com/en/stable/templating/).
57-
58-
Hyperflask includes built-ins UI components powered by [DaisyUI](https://daisyui.com/). Check out the [Components](/guides/components/#built-in-ui-components) guide.
59-
6066
## Layouts
6167

6268
Hyperflask makes managing layouts for your pages easier. Layouts are saved in the *app/layouts* folder. The default layout can be overriden at *app/layouts/default.html*.

0 commit comments

Comments
 (0)