yasoob / practical-python-projects

99 stars 42 forks source link

Replacing all the variables except for one #13

Closed jalvaradosegura closed 3 years ago

jalvaradosegura commented 3 years ago

Location Within the Book

Page: 38 Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

In this section we pass a group of variables to the template. Then we start replacing these variables within the .html file. We replace all the variables except for the 'total' variable (line 24). Im not sure why is that. After that there is an explication of single and doble curly braces and just after that there is a code block showing the whole .html file and now the 'total' variable it is used.

5 <td>
6 Price
7 </td>
8 </tr>
9
10 {% for item in items %}
11 <tr class="item">
12 <td>
13 {{item['title']}}
14 </td>
15 <td>
16 {{item['charge']}}
17 </td>
18 </tr>
19 {% endfor %}
20
21 <tr class="total">
22 <td></td>
23 <td>
24 Total: $385.00
25 </td>
26 </tr>

Possible Solutions

Replace the variable in the first iteration just like the rest of the variables

21 <tr class="total">
22 <td></td>
23 <td>
24 Total: ${{total}}
25 </td>
26 </tr>

Jorge Alberto Alvarado Segura

yasoob commented 3 years ago

Hey Jorge, so sorry for such a delayed update. COVID had me struggling for a bit but this bug is fixed in the latest version that will go out soon. Thanks ❤️