Friday, May 29

There's a bunch of places in PMT that a Markdown preview of text that's about to be submitted can be helpful. I've been using a JavaScript library called remarkable to render the Markdown preview to HTML (see markdown_preview.js).

PMT's Markdown previewer can occur in many different places on the same page, so I'm initializing each one separately. See project_action_item_modals.js, and the parts of item_detail.html that include item_detail_textarea_preview.html.

This Markdown previewer could still be more self-contained, and it's easy to wish the implementation was simpler. In Ember, you could make a Markdown previewer using an Ember Component. If you look through the Ember Blog, they seem to be heading in the direction of using Components more and more, in places where you might have found an Ember.View or an Ember.Controller in older Ember code.

React is a JavaScript framework tailored specifically for this kind of UI-centric use case. In fact, React's front page shows an example of a Markdown preview component. I haven't made anything in React yet, and JSX still seems strange to me. But because manipulating DOM elements with JavaScript requires so much meticulous attention to various details, some kind of virtual "JavaScript-aware" DOM is ultimately necessary. At that point, to rely so heavily on rendering everything using JavaScript in the user's browser, you lose the simplicity of visiting a web site, downloading an HTML document, and displaying it. There's an answer to that problem as well. You can render the page on both the server and client using the same JavaScript code, with the concepts behind Ember FastBoot and the Isomorphic JavaScript trend.

In summary, I'll try to clean up PMT's Markdown previewer into a cleaner conceptual model. I also wonder if isomorphic javascript is preferable to traditional javascript applications, and if they will ever become the norm.