I find the popularity of JSX-style templating really surprising.

    

Conditional Display and Looping in JSX

    {this.state.items.map(item => ( item.show ?
  • {item.name}
  • : null ))}
That seems like such an unintuitive way of implementing loops and if statements!

I helped design the Django template language, where the above would look like this instead:

    

Conditional Display and Looping in Django Template

    {% for item in items %} {% if item.show %}
  • {{ item.name }}
  • {% endif %} {% endfor %}
I do like the type signature aspect of it that you're talking about - I've found myself wanting that for Django templates in the past, to the point that I've started figuring out patterns for populating templates using typed Python dataclasses as opposed to anything-goes-dictionaries.

Unintuitive? It's just JavaScript, probably indistinguishable from any language that has ternary statements and .map methods.

Personally I think ternarys should die in a fire. I despise them. Like, of all the thing validly deserving of syntactic sugar... that's the case that's "important"? It's neither especially common, nor is the sugar very nice to read.

As soon as you need a 3rd leg you have to rewrite it as a full blown if/case/whatever anyway.

Not sure why this is getting downvotes. Ternaries are at best a necessary evil in JSX. We'll all be rejoicing when pattern matching finally lands in JS [1].

[1] https://github.com/tc39/proposal-pattern-matching