4 ms·
What's wrong with just using the JavaScript/TypeScript syntax you already have? It's trivial to write a few functions to create HTML elements and append childre
by peterkelly 10y ago
What's wrong with just using the JavaScript/TypeScript syntax you already have? It's trivial to write a few functions to create HTML elements and append children. For example:
import { h1, div, span, text } from 'html';
const user = { name: 'Dave', age: '30' };
return div('container',
h1(text('User info')),
div(span('field',text('Name')),text(user.name)),
div(span('field',text('Age')),text(user.age)),
);
I don't understand why there's so much activity in creating new languages/language extensions that duplicate functionality that can already be expressed as is, with just a bit of basic library support.
CSS preprocessors are another example. Want to add loops, conditionals, and user defined functions to your CSS superset? Why not just use JS/TS instead, which has all the control features and can output CSS text just as well as Less/Sass/SCSS/flavour of the month.
- Zezima 10y agoYou just wrote elm code in javascript
- abritinthebay 10y agoThat style was old before Elm. Elm does it rather well tho
- hyperhopper 10y agoMithril does this, and I find its syntax much cleaner and easier to write in than JSX. view: function(ctrl) { return m("div", [ ctrl.pages().map(function(page) { return m("a", {href: page.url}, page.title); }), m("button", {onclick: ctrl.rotate}, "Rotate links") ]); } http://mithril.js.org/ http://mithril.js.org/