File tree Expand file tree Collapse file tree 1 file changed +46
-4
lines changed
Expand file tree Collapse file tree 1 file changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,52 @@ template = t"<div>{name}</div>"
365365```python314
366366name = "world"
367367template = t"<div>{name}</div>"
368+ list(template)
369+ # ["<div>", Interpolation(value="world"), "</div>"]
370+ ```
371+ ```python314
372+ name = "world"
373+ template = t"<div>{name}</div>"
374+ template.strings
375+ # ("<div>", "</div>")
376+ ```
377+ ```python314
378+ name = "world"
379+ template = t"<div>{name}</div>"
380+ template.interpolations
381+ # (Interpolation(value="world"),)
382+ ```
383+ ```python314
384+ name = "world"
385+ template = t"<div>{name}</div>"
386+ template.interpolations
387+ # (Interpolation(
388+ # value="world",
389+ # expression="name",
390+ # conversion=None,
391+ # format_spec="",
392+ # ))
393+ ```
394+ ```python314
395+ name = "world"
396+ template = t"<div>{name!s:>10}</div>"
397+ template.interpolations
398+ # (Interpolation(
399+ # value="world",
400+ # expression="name",
401+ # conversion="s",
402+ # format_spec=">10",
403+ # ))
404+ ```
405+ ```python314
406+ name = "world"
407+ template = t"<div>{name}</div>"
408+ list(template)
409+ # ["<div>", Interpolation("world"), "</div>"]
410+ ```
411+ ```python314
412+ name = "world"
413+ template = t"<div>{name}</div>"
368414for item in template:
369415 ...
370416```
@@ -403,11 +449,7 @@ for item in template:
403449 if isinstance(item, str):
404450 print("static:", item)
405451 else:
406- # `item` is a `string.templatelib.Interpolation`
407452 print("dynamic:", item.value)
408- # static: <div>
409- # dynamic: world
410- # static: </div>
411453```
412454```python314
413455name = "world"
You can’t perform that action at this time.
0 commit comments