The point of my last reply was that it’s not a private message only for me, but only on forum. People (especially in “AI-era”) absolutely love to copy-paste stuff without thinking. Some time ago I believed that developers are a group of smart people that would not allow push themselves into any edge, but I was proved wrong as people either are scared or fascinated about “AI” - almost all I see “I fear that I would lose a job” or “how to do literally everything in AI” type of posts/responses/blogs and so on …
Emm … how to say that … Firstly thanks for your trust, but it’s not how it works … It’s your point and you have to prove it. You can’t just ask people to prove your point for you.
As said for me counter more fits component than page and all you show is assign of some class. I said that I would rather split the page on a logic and a template files for better tracking git changes. Therefore I would rather not write such code anyway. I would assign for example a boolean for a dark version of element or a theme atom and set the proper class in the template.
So no, I can’t see your point and it’s not because I’m not enough experienced. We just talk about completely different approaches. I don’t know or prefer yours, so I would not provide better example than you. Am I wrong somehow?
For sure not saying that your approach is wrong. Even if I would judge (which I don’t want to) I can’t do it properly not seeing your point.
Oh, you want to make it like a document.createElement(…) in JavaScript? Well … you would end up with some kind of DSL like in temple package, but you would immediately loose all LiveView features and “end” in:
end
end
end
hell … For now HEEx is best and I don’t see how it could be even improved. Maybe if Hologram would support calling any JavaScript API from Elixir then you could do it with functions, but they would require to write much more code than a DSL or template which is rather against Elixir’s 10x less LOC rule, so after all most people would see it as bad practice anyway.
If you agree with before at best you would have to write a complete HTML framework which is rather not worth especially if you would end up only with a bunch of functions to generate something that other projects like LiveView have with tons of features. Simply almost nobody would pay attention to a framework that only don’t support templates i.e. something most people are already used to. You would need a real alternative which requires a lot of time and resources and therefore most people don’t see it worth.
Even if you do so you would end up with tons of naming problems as HTML naming is very generic … For example how would you call a div function?
div - is terribly bad as people would be confused with arithmetic operation
element or elem - like a elem/2 for taking element from Tuple?
In fact your framework would be good only if people would always alias your module instead of import it. I don’t complain as it’s my preference, but look for all the code generated by phx generators. They use import all the time for templates, for ecto API and so on … There is lots of people just used to it and people who would not prefer other style - at least not easily …
alias MyLib.HTML
some_data
|> HTML.div(…)
# more code …
No matter if we like it or not template become a “community standard”. You would need a very, very solid API to change the way of thinking of all developers used to it and accepted it as something “normal”. As said I like aliasing more than importing as I like explicit naming in my code, so if you would work on it I may be interested.
However I’m not sure if I would change my opinion on splitting logic and template for pages. I may do a similar thing for a deisgn helper modules, so at the very end I may or may not end up doing something similar using a different API. I would say that you would have to be very, very creative to do something good on top of such old HTML naming. Unfortunately for me it does not look realistic and/or worth working on full-time for the above reasons.
For me said “barrier” was never a problem. I’m curious and so I investigated other ways, but didn’t found anything that would give me something “special”, so I would change my way of writing the code … In fact for the same reason mentioned above I rather want to have logic and template to be separated. Maybe it’s because I’m just too used to templates, but for now I don’t see anything promising enough to change my mind …