Having had careers using C# and Java, I have to agree with Serkan and Rahul. We’ve seen this progression of technology in other language and tech stacks. It’s actually not all that new. The isomoprhic APIs are. But componentization? Not so much. And from those other tech stacks we know that there are other (mostly human) factors to consider with regard to onboarding programmers, integrating the design cycle, etc. Isomorphic componentization is a big win; but it also comes at a high cost for existing code-bases, workflows, team structures, etc.
tl;dr - HTML and CSS may have 20 years of kludges and hacks baked into them (ug), but they’re used by a billion people. They’re obviously doing something right.
It would be great to see an HTML.parseJson()
function, so that we could take the above example, and do something like the following:
Template.__checkName("about");
Template["about"] = new Template("Template.about", (function() {
var view = this;
// using the html2json library here
var jsonFromHtml = {
tag: 'div',
class: 'content',
child: [{
tag: 'h2',
text: 'Title'
},{
tag: 'some-other-element',
attr: {
class: ['other', 'foo'],
someproperty: function() {
return Spacebars.mustache(view.lookup("currentEmail"));
}
}
}]
};
return HTML.parseJson(jsonFromHtml)
);
}));
If htmljs
had a parseJson()
function, I feel like I’d be a lot closer to being able to upgrade my existing apps towards React and Famo.us. That is, I’d know that my refactor path begins by refactoring my HTML files into JSON (which I could write a batch script for, or add to the starrynight utility more likely), and I’d know that JSON object works with Blaze. With that compilation point and refactor path done, it then becomes a question of writing React, Famo.us, and D3 methods to consume that JSON object and generate the necessary DOM trees in those UI layers.
With this kind of approach, I’d still be comfortable onramping junior developers, integrating designers and their design workflows, creating webcomponents using Blaze as per the W3C, and using most all of the latest/newest pure-javascript libraries. There would be one clear (and obvious) refactor path along a continuum towards pure javascript; and everything would fall nicely into place.