You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aware of the limitations of older template engines like Jinja2 and Django templates, the Python web community is increasingly reaching for libraries like htpy, htmy, and domonic, as well as frameworks like FastHTML for HTML "templating" in Python itself.
The tailwind vscode plugin doesn't quite work today for Python. For instance, consider this hack-ish configuration:
Using htpy as an example, simple lines like this get intellisense:
importhtpyashdefavatar(user: User) ->h.Renderable:
# tailwind plugin works fine here; colors are displayed, hovering over classes works, etc.returnh.div(class_="font-bold text-blue-700")[user.name]
But class_ in this case can also coalesce multiple values; here, the plugin does not work:
defavatar2(user: User) ->h.Renderable:
returnh.div(
class_=[
"font-bold text-blue-700", # no colors, no hovering, etc.user.is_vipand"more-classes-here",
]
)[user.name]
Stepping back, these newer libraries in Python-land look to me a lot like Hyperscript did in JavaScript-land before JSX arrived. There are efforts to add core language features for templating to Python but even if and when they ship, it'll take a while for community support to become widespread. Until then, HTML-in-Python builders are probably here to stay!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Aware of the limitations of older template engines like Jinja2 and Django templates, the Python web community is increasingly reaching for libraries like htpy, htmy, and domonic, as well as frameworks like FastHTML for HTML "templating" in Python itself.
The tailwind vscode plugin doesn't quite work today for Python. For instance, consider this hack-ish configuration:
Using
htpy
as an example, simple lines like this get intellisense:But
class_
in this case can also coalesce multiple values; here, the plugin does not work:Stepping back, these newer libraries in Python-land look to me a lot like Hyperscript did in JavaScript-land before JSX arrived. There are efforts to add core language features for templating to Python but even if and when they ship, it'll take a while for community support to become widespread. Until then, HTML-in-Python builders are probably here to stay!
Beta Was this translation helpful? Give feedback.
All reactions