Earlier quoted context omitted.
> Nice write up, however personally I'd take ERB over Phlex a million times. Agreed. This has been tried so many times, and non of them really "stuck". HAML, slim, liquid and now phlex. All "DSLs" to some extent that solve the problem of "not having to write HTML". Is that a problem, really? People writing Rails apps are developing web-apps. Writing HTML is part of the skillset, and of all the things in a Rails app,…
The thing I really like about Phlex is that it's not a full DSL, it's not its own language. It's an expressive Ruby API and the resulting code has the regular Ruby toolbox available. Ruby devs often call this a "DSL" and I lean away from that use of the term because I think it adds confusion in situations like this. But Phlex feels like a breath of fresh air because it's composable, testable, "just ruby", and has a l…
There is no distinction in Phlex. The distinction is only made in generated code in Phlex-Rails where it felt like a sensible way to fit with the existing mental model. Views are technically just components, but they are expected to be HTML documents composed of components and rendered directly from controller actions. You wouldn’t want to render a view inside another component because you’d get another doctype and `` tag. So they are sort of “entry points”.
> There's a little metaprogramming in SGML::Elements I dislike
Many crimes are committed in the name of performance. For example, we have a different code path for standard elements with attributes and content, standard elements with attributes but no content, standard elements with content but no attributes and standard elements with no attributes or content. Not to mention void elements.
This allows us to reduce the number of string concatenation operations required during rendering and is why it renders ~1.5gbps of HTML per core.
I’ve considered having an API-compatible minimal version of Phlex that would be much easier to take on and maintain yourself if it didn’t make all these performance optimisations.