by ggregoire · 10y ago · 0 comments
Let's not forget how horrible Angular templating was:
<ul ng-if="::vm.items.length">
<li ng-class="::{ 'active': item.active }" ng-repeat="item in ::vm.items | orderBy: 'id' as ordered track by item.id" ng-click="item.active = !item.active">
{{::item.name}}
</li>
</ul>
<select ng-options="item.subItem as item.label for item in ::vm.items2 track by item.id" ng-model="selected"></select>
<div ng-include="selected.template.url" />Syntactically, JSX feels more native, but both are addressing the same problem.
Edit: After reading my comment again, I feel I must mention; even that similarity is not coming from React directly. It's JSX. Although they go like fish & chips together (Not a great analogy but I guess I'm hungry).
It's a templater, read my message above - an advanced tempalter, which means it has some DOM rendering optimizations.
> The only similarity between PHP and React is that you can have tags in ("around" in PHP's case) your code.
Not just tags, but an entire "view" thing, a representation, so old fashion messy/sloppy/spaghetti-like PHP like code style.
For PHP (in its traditional form), everything around the code is just strings, which is also the case for most of the templating engines.
You can't shout "spaghetti code" every time you see XML tags in code. Think Scala or VB.
the notion that your view logic and it's template must be completely decoupled is an antiquated and misguided best practice.