8000 Removes a comment issue that was causing a template syntax error in t… · coding794/complete-python-course@f0e936e · GitHub
[go: up one dir, main page]

Skip to content

Commit f0e936e

Browse files
committed
Removes a comment issue that was causing a template syntax error in the lecture 3 starting code for section 15. Also reformats many of the comments in the templates for this section, as many were extremely long and extended far off the screen.
1 parent c85d40e commit f0e936e

File tree

10 files changed

+50
-30
lines changed

10 files changed

+50
-30
lines changed

course_contents/15_flask/projects/first-flask-app-lectures/3-rendering-html/templates/post.jinja2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<head></head>
33
<body>
44

5-
<!-- This is a HTML comment, so it doesn't get executed by the browser! -->
6-
<!-- The below are variables that will get replaced by their values (as if they were Python). They must be inside {{ }} in order to do that. -->
5+
<!-- This is a HTML comment, so it doesn't get executed by the browser!
6+
Below are variables that will get replaced by their values just like in Python.
7+
The variable names must be inside double curly braces in order to be replaced -->
8+
79
<h1>{{ post['title'] }}</h1>
810
<p>{{ post['content'] }}</p>
911

course_contents/15_flask/projects/first-flask-app-lectures/4-error-pages/templates/404.jinja2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!-- Use the base.jinja2 template. We can then override blocks defined there and "fill them in". -->
22
{% extends 'base.jinja2' %}
33

4-
<!-- Replace the `content` block with whatever we put inside it... -->
5-
<!-- In this case a title saying "404", and the contents of the `message` variable. -->
4+
<!-- Replace the `content` block with whatever we put inside it...
5+
In this case a title saying "404", and the contents of the `message` variable. -->
6+
67
{% block content %}
78
<h1>404 — Post not found</h1>
89
<p>{{ message }}</p>

course_contents/15_flask/projects/first-flask-app-lectures/4-error-pages/templates/base.jinja2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<!DOCTYPE html>
22
<head></head>
33
<body>
4-
<!-- This is a generic Jinja2 template which defines a block. It doesn't use any variables (so it won't actually show any content.) -->
5-
<!-- Other templates can however fill in this block with their own content. That means we won't need to duplicate e.g. `DOCTYPE`.-->
4+
<!-- This is a generic Jinja2 template which defines a block. It doesn't us 8000 e any
5+
variables (so it won't actually show any content.) Other templates can however
6+
fill in this block with their own content. That means we won't need to duplicate e.g. `DOCTYPE`.-->
7+
68
{% block content %}
79

810
{% endblock %}

course_contents/15_flask/projects/first-flask-app-lectures/4-error-pages/templates/post.jinja2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!-- Use the base.jinja2 template. We can then override blocks defined there and "fill them in". -->
22
{% extends 'base.jinja2' %}
33

4-
<!-- Replace the `content` block with whatever we put inside it... -->
5-
<!-- In this case, a title with the `post['title']` and a paragraph with the `post['content']`. -->
4+
<!-- Replace the `content` block with whatever we put inside it...
5+
In this case, a title with the `post['title']` and a paragraph with the `post['content']`. -->
6+
67
{% block content %}
78
<h1>{{ post['title'] }}</h1>
89
<p>{{ post['content'] }}</p>

course_contents/15_flask/projects/first-flask-app-lectures/5-rendering-forms/templates/create.jinja2

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@
33
{% block content %}
44
<!-- Here the contents are a title and a form.-->
55
<h1>Create post</h1>
6-
<form action="/post/create"> <!-- The action is what route to send data to -->
7-
<div> <!-- A div is just a block element; makes other elements appear below this one instead of side by side. -->
8-
<label for="title">Title</label> <!-- A label is some text associated with an element. It's particularly useful for screen readers. -->
9-
<input type="text" name="title" id="title" /> <!-- A "text" input is a normal text field. -->
6+
<!-- The action is what route to send data to -->
7+
<form action="/post/create">
8+
<!-- A div is just a block element; makes other elements appear below this one instead of side by side. -->
9+
<div>
10+
<!-- A label is some text associated with an element. It's particularly useful for screen readers. -->
11+
<label for="title">Title</label>
12+
<!-- A "text" input is a normal text field. -->
13+
<input type="text" name="title" id="title" />
1014
</div>
1115

1216
<div>
1317
<label for="content">Content</label>
14-
<textarea name="content" id="content"></textarea> <!-- A textarea is another type of input which can span multiple lines of text. -->
18+
<!-- A textarea is another type of input which can span multiple lines of text. -->
19+
<textarea name="content" id="content"></textarea>
1520
</div>
1621

1722
<div>
18-
<input type="submit"> <!-- When you have a "submit" input, this will send the data in the form to the `action` when pressed. -->
23+
<!-- When you have a "submit" input, this will send the data in the form to the `action` when pressed. -->
24+
<input type="submit">
1925
</div>
2026
</form>
2127
{% endblock %}

course_contents/15_flask/projects/first-flask-app-lectures/6-forms-with-post/templates/create.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{% block content %}
44
<h1>Create post</h1>
55
<form action="/post/create" method="POST">
6-
<!-- The action is what route to send data to; the method is how to send the data. -->
7-
<!-- using GET sends data as query string parameters; using POST sends it hidden inside the form payload. -->
6+
<!-- The action is what route to send data to; the method is how to send the data.
7+
using GET sends data as query string parameters; using POST sends it hidden inside the form payload. -->
88
<div>
99
<label for="title">Title</label>
1010
<input type="text" name="title" id="title" />

course_contents/15_flask/projects/first-flask-app-lectures/7-single-endpoint-for-form/templates/create.jinja2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
{% block content %}
44
<h1>Create post</h1>
55
<form method="POST">
6-
<!-- The action has now been removed, and then it defaults to "this page". -->
7-
<!-- Since we're loading the form AND receiving the data on the same route, we don't need to specify the `action` anymore. -->
6+
<!-- The action has now been removed, and then it defaults to "this page".
7+
Since we're loading the form AND receiving the data on the same route,
8+
we don't need to specify the `action` anymore. -->
9+
810
<div>
911
<label for="title">Title</label>
1012
<input type="text" name="title" id="title" />

course_contents/15_flask/projects/first-flask-app-lectures/8-jinja-for-loops/templates/home.jinja2

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
{% block content %}
44
<h1>Welcome to your blog.</h1>
5-
<h2>Posts</h2> <!-- Here we've got a slightly smaller heading -->
6-
<ul> <!-- This bullet point list will show a link for each post. -->
7-
{% for post_id, post in posts.items() %} <!-- This is very similar to Python, but it's a Jinja2 for loop—looks the same and even we have .items for the dictionary -->
8-
<li><a href="{{ url_for('post', post_id=post_id) }}">{{ post['title'] }}</a></li> <!-- Here we use url_for to take us to the appropriate route. -->
5+
<!-- Here we've got a slightly smaller heading -->
6+
<h2>Posts</h2>
7+
<!-- This bullet point list will show a link for each post. -->
8+
<ul>
9+
<!-- This is very similar to Python, but it's a Jinja2 for loop—looks the same and even we have .items for the dictionary -->
10+
{% for post_id, post in posts.items() %}
11+
<!-- Here we use url_for to take us to the appropriate route. -->
12+
<li><a href="{{ url_for('post', post_id=post_id) }}">{{ post['title'] }}</a></li>
913
{% endfor %}
1014
</ul>
1115
{% endblock %}
1216

13-
<!--
14-
We could do this instead:
17+
<!-- We could do the following instead. Make sure to have double curly braces; ommitted here just so it doesn't break the file.
1518
1619
<ul>
17-
<li><a href="/post/0">{ posts[0]['title'] }</a></li> <!-- Make sure to have double curly braces; ommitted here just so it doesn't break the file. -->
20+
<li><a href="/post/0">{ posts[0]['title'] }</a></li>
1821
<li><a href="/post/1">{ posts[1]['title'] }</a></li>
1922
</ul>
2023
21-
But of course, that would give an error if we don't have sufficient posts—and as we add new posts they wouldn't appear in the list.
22-
-->
24+
But of course, that would give an error if we don't have sufficient posts—andas we add
25+
new posts they wouldn't appear in the list. -->

course_contents/15_flask/projects/first-flask-app-lectures/9-adding-home-link/templates/base.jinja2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!DOCTYPE html>
22
<head></head>
33
<body>
4-
<a href="{{ url_for('home') }}">Home</a> <!-- We add this in base.jinja2 and outside the content block so that it is not overridden by other pages. -->
4+
<!-- We add this in base.jinja2 and outside the content block so that it is not overridden by other pages. -->
5+
<a href="{{ url_for('home') }}">Home</a>
56
{% block content %}
67

78
{% endblock %}

course_contents/15_flask/projects/first-flask-app-lectures/9-adding-home-link/templates/create.jinja2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
{% block content %}
44
<h1>Create post</h1>
55
<form method="POST">
6-
<!-- The action has now been removed, and then it defaults to "this page". -->
7-
<!-- Since we're loading the form AND receiving the data on the same route, we don't need to specify the `action` anymore. -->
6+
<!-- The action has now been removed, and then it defaults to "this page".
7+
Since we're loading the form AND receiving the data on the same route,
8+
we don't need to specify the `action` anymore. -->
9+
810
<div>
911
<label for="title">Title</label>
1012
<input type="text" name="title" id="title" />

0 commit comments

Comments
 (0)
0