Hacker News new | ask | show | jobs
by reverius42 4193 days ago
A year ago, I would have agreed (that templating is cleaner, better separation, and going back to generating HTML from code would be a step backwards). Since I have been using React.js, my opinion has changed 100% -- and I realized that the supposed "separation of concerns" that drove us to template languages in the first place was an arbitrary separation. Separating components (a button, a form, a site header, what have you) is the kind of separation you want, not separating languages arbitrarily. If you look at the evolution of template languages, they sometimes start simple, but all of them have added sufficient logic to approach or surpass turing-completeness -- it turns out that you want to write templates with logic in them, that that is actually how you separate concerns effectively. The logic and rendered markup for a particular component should be cohesive; components should be loosely coupled together.
1 comments

I pretty much agree with the reasoning how templating doesn't promote anything other than separation of languages. It always frowned how people emphasised templates being logic-less, which imo oversimplifies the matter.

Yet i still don't seem comfortable writing the markup in js. Even react's JSX preprocessor doesn't seem right to me.