File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -116,18 +116,22 @@ template = t"Hello, {friend}!" # 😊
116116
117117```` md magic-move
118118```python314
119+ name = "world"
119120type(f"Hello, {name}!")
120121```
121122```python314
123+ name = "world"
122124type(f"Hello, {name}!")
123125# <class 'str'>
124126```
125127```python314
128+ name = "world"
126129type(f"Hello, {name}!")
127130# <class 'str'>
128131type(t"Hello, {name}!")
129132```
130133```python314
134+ name = "world"
131135type(f"Hello, {name}!")
132136# <class 'str'>
133137type(t"Hello, {name}!")
@@ -359,6 +363,19 @@ for item in template:
359363```python314
360364name = "world"
361365template = t"<div>{name}</div>"
366+ for item in template:
367+ if isinstance(item, str):
368+ print("static:", item)
369+ else:
370+ # `item` is a `string.templatelib.Interpolation`
371+ print("dynamic:", item.value)
372+ # static: <div>
373+ # dynamic: world
374+ # static: </div>
375+ ```
376+ ```python314
377+ name = "world"
378+ template = t"<div>{name}</div>"
362379parts = []
363380for item in template:
364381 if isinstance(item, str):
@@ -549,7 +566,7 @@ def user_details(user: User, attribs: dict | None = None) -> Template:
549566def user_page(uid: str):
550567 user = get_user_from_db(uid)
551568 attribs = {"id": uid, "class": ["user", "active"]}
552- return html(user_details(user, attribs)) # 🪄
569+ return html(user_details(user, attribs)) # 🪄🪄🪄🪄🪄🪄 🪄
553570```
554571````
555572</div >
You can’t perform that action at this time.
0 commit comments