Skip to content

Commit 5e791fb

Browse files
committed
Done done done
1 parent 733a958 commit 5e791fb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

slides.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,22 @@ template = t"Hello, {friend}!" # 😊
116116

117117
````md magic-move
118118
```python314
119+
name = "world"
119120
type(f"Hello, {name}!")
120121
```
121122
```python314
123+
name = "world"
122124
type(f"Hello, {name}!")
123125
# <class 'str'>
124126
```
125127
```python314
128+
name = "world"
126129
type(f"Hello, {name}!")
127130
# <class 'str'>
128131
type(t"Hello, {name}!")
129132
```
130133
```python314
134+
name = "world"
131135
type(f"Hello, {name}!")
132136
# <class 'str'>
133137
type(t"Hello, {name}!")
@@ -359,6 +363,19 @@ for item in template:
359363
```python314
360364
name = "world"
361365
template = 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>"
362379
parts = []
363380
for item in template:
364381
if isinstance(item, str):
@@ -549,7 +566,7 @@ def user_details(user: User, attribs: dict | None = None) -> Template:
549566
def 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>

0 commit comments

Comments
 (0)