Skip to content

Commit 9031248

Browse files
committed
Updated docs
1 parent 0ad3c2c commit 9031248

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/examples.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,31 @@ Tested on ESP32-S2 Feather.
170170
:emphasize-lines: 26-28,41,52,68,74
171171
:linenos:
172172

173+
Templates
174+
---------
175+
176+
With the help of the ``adafruit_templateengine`` library, it is possible to achieve somewhat of a
177+
server-side rendering of HTML pages.
178+
179+
Instead of using string formatting, you can use templates, which can include more complex logic like loops and conditionals.
180+
This makes it very easy to create dynamic pages, witout using JavaScript and exposing any API endpoints.
181+
182+
Templates also allow splitting the code into multiple files, that can be reused in different places.
183+
You can find more information about the template syntax in the
184+
`adafruit_templateengine documentation <https://docs.circuitpython.org/projects/templateengine/en/latest/>`_.
185+
186+
.. literalinclude:: ../examples/directory_listing.tpl.html
187+
:caption: examples/directory_listing.tpl.html
188+
:language: django
189+
:lines: 5-
190+
:emphasize-lines: 3-4,8,12,17-25,29
191+
:linenos:
192+
193+
.. literalinclude:: ../examples/httpserver_templates.py
194+
:caption: examples/httpserver_templates.py
195+
:emphasize-lines: 12-15,49-55
196+
:linenos:
197+
173198
Form data parsing
174199
---------------------
175200

0 commit comments

Comments
 (0)