Reputation: 2340
What is the purpose of inserting t
before $
symbol when making HTML templates in python web.py framework:
$def with (todos)
<ul>
$for todo in todos:
<li id="t$todo.id">$todo.title</li> <!-- at this line of code -->
</ul>
From web.py documentation of making simple todo web app when selecting todos from database table by item id
i didn't find any reference for the purpose of putting t
before $
in t$todo.id
.
Any help on this issue will be appreciated.
Upvotes: 0
Views: 87
Reputation: 5802
I think this is too long for a comment, so I post it as answer.
The important thing to understand here is that rendering engines go through the template and look for special elements that are then replaced or processed in some other way. In this case, special elements are obviously marked by a dollar sign. Everything else is just carried over to the output literally, such as the html tags and the t
before the variable $todo.id
.
So, if the template contains the pattern <li id="t$todo.id">
, the renderer will recognize $todo.id
and replace it with the corresponding value, e.g., 5
. The rest is just copied, so you get <li id="t5">
. I guess it's just to make the ids more meaningful for easier access via CSS or JavaScript. You could omit the t
as well or replace it with something else:
<li id="$todo.id"> => <li id="5">
<li id="todo$todo.id"> => <li id="todo5">
<li id="really-important$todo.id"> => <li id="really-important5">
Upvotes: 1