JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.3/ember.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
<script type="text/x-handlebars">
<div class="commentBox">
<h1>Comments</h1>
<div class="commentList">
{{#each controller}}
<div class="comment">
<h2 class="commentAuthor">
{{author}}
</h2>
<span>{{markdown text}}</span>
</div>
{{/each}}
</div>
{{input value=author placeholder="Your name"}}
{{input value=text placeholder="Say something..."}}
<input type="submit" value="Add" {{action addComment}} />
</div>
</script>
JavaScript
App = Ember.Application.create();
App.ApplicationController = Ember.ArrayController.extend({
model: [],
content: [
{ author: "Arthur", text: "This is awesome" },
{ author: "Ember", text: "Another comment" }
],
addComment: function() {
var comment = {
author: this.get("author"),
text: this.get("text")
};
this.pushObject(comment);
$.post("http://example.com", function(comments) {
this.set("content", comments);
});
this.set("author", "")
this.set("text", "")
},
init: function () {
this._super();
(function poll() {
$.get("http://example.com", function (comments) {
this.set("content", comments);
setTimeout(poll, 5000);
});
})();
}
});
Ember.Handlebars.registerBoundHelper('markdown', function(value, options) {
var converter = new Showdown.converter();
return new Handlebars.SafeString( converter.makeHtml(value || '') );
});