Skip to content

Commit e1fa6f8

Browse files
committed
adding new template engine page
1 parent ee4e9cb commit e1fa6f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+561
-1
lines changed

about-author.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
120120
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
121121
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
122122
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
123+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
123124
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
124125
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
125126
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

all.html

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ <h2>New to programming</h2>
415415
free book by Zed Shaw.</p>
416416
</li>
417417
<li>
418+
<p>The <a href="https://www.twilio.com/blog/tag/python">Python projects tag</a> on the
419+
Twilio blog is constantly updated with fun tutorials you can build to
420+
learn Python, such as the
421+
<a href="https://www.twilio.com/blog/2015/11/international-space-station-notifications-with-python-redis-queue-and-twilio-copilot.html">International Space Station Tracker with Flask and Redis-Queue</a>,
422+
<a href="https://www.twilio.com/blog/2014/11/choose-your-own-adventure-presentations-with-reveal-js-python-and-websockets.html">Choose Your Own Adventures Presentations using Flask and WebSockets</a>
423+
and <a href="https://www.twilio.com/blog/2015/11/getting-started-with-opencv-and-python-featuring-the-martian-2.html">Martianify Photos with OpenCV</a>.</p>
424+
</li>
425+
<li>
418426
<p><a href="http://www.diveinto.org/python3/">Dive into Python 3</a> is an open source
419427
book provided under the Creative Commons license and available in HTML or
420428
PDF form.</p>
@@ -2879,6 +2887,94 @@ <h2>Python-specific WebSockets resources</h2>
28792887
has some interesting comments on what's missing from the above content that
28802888
I'm working to address.</p>
28812889
</li>
2890+
</ul>
2891+
<h1>Template Engines</h1>
2892+
<p>Template engines process template files, which provide an intermediate format
2893+
between your Python code and a desired output format, such as HTML or PDF.</p>
2894+
<h2>Why are template engines important?</h2>
2895+
<p>Template engines allow developers to generate a desired content type, such
2896+
as HTML, while using some of the data and programming constructs such as
2897+
conditionals and for loops to manipulate the output. Template files that are
2898+
created by developers and then processed by the template engine consist of
2899+
prewritten markup and template tag blocks where data is inserted.</p>
2900+
<p>For example, look at the first ten source lines of HTML of this webpage:</p>
2901+
<div class="highlight"><pre><span class="cp">&lt;!DOCTYPE html&gt;</span>
2902+
<span class="nt">&lt;html</span> <span class="na">lang=</span><span class="s">&quot;en&quot;</span><span class="nt">&gt;</span>
2903+
<span class="nt">&lt;head&gt;</span>
2904+
<span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;Content-Type&quot;</span> <span class="na">content=</span><span class="s">&quot;text/html; charset=UTF-8&quot;</span><span class="nt">&gt;</span>
2905+
<span class="nt">&lt;meta</span> <span class="na">charset=</span><span class="s">&quot;utf-8&quot;</span><span class="nt">&gt;</span>
2906+
<span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;X-UA-Compatible&quot;</span> <span class="na">content=</span><span class="s">&quot;IE=edge&quot;</span><span class="nt">&gt;</span>
2907+
<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;viewport&quot;</span> <span class="na">content=</span><span class="s">&quot;width=device-width, initial-scale=1.0&quot;</span><span class="nt">&gt;</span>
2908+
<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;author&quot;</span> <span class="na">content=</span><span class="s">&quot;Matt Makai&quot;</span><span class="nt">&gt;</span>
2909+
<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;description&quot;</span> <span class="na">content=</span><span class="s">&quot;Template engines provide programmatic output of formatted content such as HTML, XML or PDF.&quot;</span><span class="nt">&gt;</span>
2910+
<span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">&quot;shortcut icon&quot;</span> <span class="na">href=</span><span class="s">&quot;//static.fullstackpython.com/fsp-fav.png&quot;</span><span class="nt">&gt;</span>
2911+
</pre></div>
2912+
2913+
2914+
<p>Every one of the HTML lines above is standard for each page on Full Stack Python,
2915+
with the exception of the <code>&lt;meta name="description"...</code> line which provides
2916+
a unique short description of what the individual page contains.</p>
2917+
<p>The <a href="https://github.com/makaimc/fullstackpython.com/blob/gh-pages/source/theme/templates/base.html">base.html Jinja template</a> used to generate Full Stack Python
2918+
allows every page on Full Stack Python to have consistent HTML but
2919+
dynamically generate the pieces that should change between pages when
2920+
the <a href="/static-site-generator.html">static site generator</a> executes. The below
2921+
code from the <code>base.html</code> template shows that the meta description is up to child
2922+
templates to create.</p>
2923+
<div class="highlight"><pre><span class="cp">&lt;!DOCTYPE html&gt;</span>
2924+
<span class="nt">&lt;html</span> <span class="na">lang=</span><span class="s">&quot;en&quot;</span><span class="nt">&gt;</span>
2925+
<span class="nt">&lt;head&gt;</span>
2926+
<span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;Content-Type&quot;</span> <span class="na">content=</span><span class="s">&quot;text/html; charset=UTF-8&quot;</span><span class="nt">&gt;</span>
2927+
<span class="nt">&lt;meta</span> <span class="na">charset=</span><span class="s">&quot;utf-8&quot;</span><span class="nt">&gt;</span>
2928+
<span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;X-UA-Compatible&quot;</span> <span class="na">content=</span><span class="s">&quot;IE=edge&quot;</span><span class="nt">&gt;</span>
2929+
<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;viewport&quot;</span> <span class="na">content=</span><span class="s">&quot;width=device-width, initial-scale=1.0&quot;</span><span class="nt">&gt;</span>
2930+
<span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;author&quot;</span> <span class="na">content=</span><span class="s">&quot;Matt Makai&quot;</span><span class="nt">&gt;</span>
2931+
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">meta_header</span> <span class="cp">%}{%</span> <span class="k">endblock</span> <span class="cp">%}</span>
2932+
<span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">&quot;shortcut icon&quot;</span> <span class="na">href=</span><span class="s">&quot;//static.fullstackpython.com/fsp-fav.png&quot;</span><span class="nt">&gt;</span>
2933+
</pre></div>
2934+
2935+
2936+
<p>In a typical <a href="/wsgi-servers.html">WSGI application</a>, the template engine would
2937+
generate the HTML output response when an HTTP request comes in for a
2938+
particular URL. </p>
2939+
<h2>Python template engines</h2>
2940+
<p>There are several popular Python template engines. Template engines have to
2941+
walk the spectrum between allowing arbitrary code execution and granting only
2942+
a limited set of capabilities via template tags.</p>
2943+
<h3>Jinja</h3>
2944+
<p><a href="http://jinja.pocoo.org/">Jinja</a>, also known as "Jinja2" is a popular Python
2945+
template engine written as an independent open source project, unlike some
2946+
template engines that are provided as part of a larger web framework.</p>
2947+
<p>Major Python open source applications such as the
2948+
<a href="/configuration-management.html">configuration management</a> tools Ansible
2949+
and <a href="https://github.com/saltstack/salt">SaltStack</a>
2950+
as well as the <a href="/static-site-generator.html">static site generator</a> Pelican use
2951+
the Jinja template engine by default for generating output files.</p>
2952+
<h3>Django templating</h3>
2953+
<p>Django comes with its
2954+
<a href="https://docs.djangoproject.com/en/dev/topics/templates/">own template engine</a>
2955+
in addition to supporting (as of Django 1.9) drop-in replacement with other
2956+
template engines such as Jinja.</p>
2957+
<h3>Mako</h3>
2958+
<p><a href="http://www.makotemplates.org/">Mako</a> is the default templating engine for
2959+
the <a href="/pyramid.html">Pyramid web framework</a> and has wide support as a replacement
2960+
template engine for many <a href="/other-web-frameworks.html">other web frameworks</a>.</p>
2961+
<h3>Template engine resources</h3>
2962+
<ul>
2963+
<li>
2964+
<p><a href="http://aosabook.org/en/500L/a-template-engine.html">A template engine in 500 lines or less</a>
2965+
is an article by <a href="http://nedbatchelder.com/">Ned Batchelder</a> provides a<br />
2966+
template engine in 252 lines of Python that can be used to understand how
2967+
template engines work under the cover.</p>
2968+
</li>
2969+
<li>
2970+
<p><a href="https://realpython.com/blog/python/primer-on-jinja-templating/">A Primer on Jinja Templating</a>
2971+
shows how to use the major parts of this fantastic template engine.</p>
2972+
</li>
2973+
<li>
2974+
<p><a href="http://agiliq.com/blog/2015/08/template-fragment-caching-gotchas/">Template fragment gotchas</a>
2975+
is a collection of situations that can trip up a developer or designer when
2976+
working with templates.</p>
2977+
</li>
28822978
</ul>
28832979
<h1>Web Application Security</h1>
28842980
<p>Website security must be thought about while building every level of the web

api-creation.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
347347
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
348348
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
349349
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
350+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
350351
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
351352
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
352353
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

api-integration.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
211211
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
212212
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
213213
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
214+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
214215
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
215216
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
216217
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

application-dependencies.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
280280
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
281281
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
282282
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
283+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
283284
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
284285
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
285286
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

application-programming-interfaces.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
188188
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
189189
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
190190
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
191+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
191192
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
192193
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
193194
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

best-python-resources.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ <h2>New to programming</h2>
8181
free book by Zed Shaw.</p>
8282
</li>
8383
<li>
84+
<p>The <a href="https://www.twilio.com/blog/tag/python">Python projects tag</a> on the
85+
Twilio blog is constantly updated with fun tutorials you can build to
86+
learn Python, such as the
87+
<a href="https://www.twilio.com/blog/2015/11/international-space-station-notifications-with-python-redis-queue-and-twilio-copilot.html">International Space Station Tracker with Flask and Redis-Queue</a>,
88+
<a href="https://www.twilio.com/blog/2014/11/choose-your-own-adventure-presentations-with-reveal-js-python-and-websockets.html">Choose Your Own Adventures Presentations using Flask and WebSockets</a>
89+
and <a href="https://www.twilio.com/blog/2015/11/getting-started-with-opencv-and-python-featuring-the-martian-2.html">Martianify Photos with OpenCV</a>.</p>
90+
</li>
91+
<li>
8492
<p><a href="http://www.diveinto.org/python3/">Dive into Python 3</a> is an open source
8593
book provided under the Creative Commons license and available in HTML or
8694
PDF form.</p>
@@ -315,6 +323,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
315323
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
316324
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
317325
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
326+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
318327
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
319328
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
320329
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

best-python-videos.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
245245
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
246246
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
247247
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
248+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
248249
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
249250
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
250251
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

bottle.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ <h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Ta
181181
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
182182
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
183183
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
184+
<a href="/template-engines.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Template Engines</a>
184185
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
185186
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generators</a>
186187
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>

0 commit comments

Comments
 (0)