Enaml-web is like react's JSX, just it uses python. Components are defined declaratively making them easy to read, extend, and modify. It's like using raw http with the addition of variables and programming constructs like conditional and loop statements.
Components are defined and rendered server side. This translates into an extremely fast and smooth user experience for clients. It's just HTTP. Meaning you can integrate any css framework you like, any js libraries you like, and it just works.
Built on existing and proven server frameworks such as Twisted and Tornado. Simply import the view definition, create a view with your models, and call render. When your data changes, only the nodes that changed are re-rendered, making it extremely fast (rendering is in C!).
from web.components.api import *
#: Simply replace HTML tags with the captialized name
enamldef Index(Html):
Head:
Title:
text = "Hello world"
Body:
H1:
text = "Hello world"
from web.components.api import *
#: Define a component
enamldef Icon(I):
tag = 'i'
cls = 'material-icons'
#: Then use it
enamldef Page(Html):
#: ...
Icon:
text = "android"
#: ...
from web.components.api import *
from web.core.api import Block
#: Templates can be made using `Blocks`
enamldef Base(Html):
attr user
attr site
attr request
alias content
Head:
Title:
text << site.title
Body:
Header:
text = "Header"
#: Block content be replaced in subclasses
Block: content:
pass
Footer:
text = "Footer"
#: Now just extend the base template to use it
enamldef Page(Base): page:
Block:
block = page.content
P:
text = "Replaces content!"
In case you're wondering, yes, this website is built with enaml-web!