You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/pages/index.html
+29-27Lines changed: 29 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -740,27 +740,27 @@
740
740
</li>
741
741
742
742
<liclass="md-nav__item">
743
-
<ahref="#content-pages" class="md-nav__link">
743
+
<ahref="#the-page-template" class="md-nav__link">
744
744
<spanclass="md-ellipsis">
745
-
Content pages
745
+
The page template
746
746
</span>
747
747
</a>
748
748
749
749
</li>
750
750
751
751
<liclass="md-nav__item">
752
-
<ahref="#how-routing-works" class="md-nav__link">
752
+
<ahref="#content-pages" class="md-nav__link">
753
753
<spanclass="md-ellipsis">
754
-
How routing works
754
+
Content pages
755
755
</span>
756
756
</a>
757
757
758
758
</li>
759
759
760
760
<liclass="md-nav__item">
761
-
<ahref="#the-page-template" class="md-nav__link">
761
+
<ahref="#how-routing-works" class="md-nav__link">
762
762
<spanclass="md-ellipsis">
763
-
The page template
763
+
How routing works
764
764
</span>
765
765
</a>
766
766
@@ -1924,27 +1924,27 @@
1924
1924
</li>
1925
1925
1926
1926
<liclass="md-nav__item">
1927
-
<ahref="#content-pages" class="md-nav__link">
1927
+
<ahref="#the-page-template" class="md-nav__link">
1928
1928
<spanclass="md-ellipsis">
1929
-
Content pages
1929
+
The page template
1930
1930
</span>
1931
1931
</a>
1932
1932
1933
1933
</li>
1934
1934
1935
1935
<liclass="md-nav__item">
1936
-
<ahref="#how-routing-works" class="md-nav__link">
1936
+
<ahref="#content-pages" class="md-nav__link">
1937
1937
<spanclass="md-ellipsis">
1938
-
How routing works
1938
+
Content pages
1939
1939
</span>
1940
1940
</a>
1941
1941
1942
1942
</li>
1943
1943
1944
1944
<liclass="md-nav__item">
1945
-
<ahref="#the-page-template" class="md-nav__link">
1945
+
<ahref="#how-routing-works" class="md-nav__link">
1946
1946
<spanclass="md-ellipsis">
1947
-
The page template
1947
+
How routing works
1948
1948
</span>
1949
1949
</a>
1950
1950
@@ -2026,22 +2026,28 @@ <h1 id="pages">Pages</h1>
2026
2026
<p>This feature is provided by <ahref="https://github.com/hyperflask/flask-file-routes">Flask-File-Routes</a></p>
2027
2027
</div>
2028
2028
<h2id="dynamic-pages">Dynamic pages</h2>
2029
-
<p>Dynamic pages can use the following formats:</p>
2030
-
<ul>
2031
-
<li><strong>jpy</strong>: jinjapy hybrid format that let you execute code before rendering the template</li>
2032
-
<li><strong>py</strong>: python code only</li>
2033
-
</ul>
2034
-
<p>A jinjapy file contains 2 sections:</p>
2035
-
<ul>
2036
-
<li>Some Python code enclosed by lines containg 3 dashes "---"</li>
2037
-
<li>A body containing some Jinja template code</li>
2038
-
</ul>
2039
-
<p>Both are optional:</p>
2029
+
<p>Pages use the <ahref="https://github.com/hyperflask/jinjapy">jinjapy</a> file format. It combines python code and a <ahref="#the-page-template">jinja template</a>. The python code will be executed first on every request, then the template will be rendered.</p>
<p>A special <ahref="#the-page-object">page object</a> is available in the python code. Assign values to this object so that they become available in the template.</p>
<p>Both the python code or the templates are optional:</p>
2040
2038
<ul>
2041
2039
<li>If the python code is missing, the file only contains a Jinja template</li>
2042
2040
<li>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</li>
2043
2041
</ul>
2044
2042
<p>The python code has a few global variables injected when executed: <code>page</code>, <code>request</code>, <code>abort</code>, <code>redirect</code>, <code>url_for</code>, <code>current_app</code>, <code>render_template</code>.</p>
2043
+
<divclass="admonition tip">
2044
+
<pclass="admonition-title">Tip</p>
2045
+
<p>Pages can also be declared using .py files. In this case they will be pure python modules. Use <code>page.respond()</code> to send a response.</p>
2046
+
</div>
2047
+
<h2id="the-page-template">The page template</h2>
2048
+
<p>Templates are powered by <ahref="https://jinja.palletsprojects.com/en/stable/">Jinja</a>.</p>
2049
+
<p>We recommend reading the <ahref="https://flask.palletsprojects.com/en/stable/templating/">Flask templating guide</a>.</p>
2050
+
<p>Hyperflask includes built-ins UI components powered by <ahref="https://daisyui.com/">DaisyUI</a>. Check out the <ahref="/guides/components/#built-in-ui-components">Components</a> guide.</p>
2045
2051
<h2id="content-pages">Content pages</h2>
2046
2052
<p>No python code will be executed on content pages.</p>
2047
2053
<p>Content pages can use the following formats:</p>
<p>The placeholder value is available through the <ahref="#the-page-object"><code>page</code> object</a> (eg: <code>page.slug</code>).</p>
2069
-
<h2id="the-page-template">The page template</h2>
2070
-
<p>Templates are powered by <ahref="https://jinja.palletsprojects.com/en/stable/">Jinja</a>.</p>
2071
-
<p>We recommend reading the <ahref="https://flask.palletsprojects.com/en/stable/templating/">Flask templating guide</a>.</p>
2072
-
<p>Hyperflask includes built-ins UI components powered by <ahref="https://daisyui.com/">DaisyUI</a>. Check out the <ahref="/guides/components/#built-in-ui-components">Components</a> guide.</p>
2073
2075
<h2id="layouts">Layouts</h2>
2074
2076
<p>Hyperflask makes managing layouts for your pages easier. Layouts are saved in the <em>app/layouts</em> folder. The default layout can be overriden at <em>app/layouts/default.html</em>.
2075
2077
(Hyperflask provides a default layout when none is created)</p>
0 commit comments