JSFiddle - React, Tailwind, and code Playground

by cherif_b

HTML

<script src="http://canjs.us/release/latest/can.jquery-all.js"></script>
<script src="http://canjs.us/release/latest/can.fixture.js"></script>
<script src="http://canjs.us/release/latest/can.observe.delegate.js"></script>
<div id="content"></div>

<script  type="text/ejs" id="main-tmpl">
    <ul>
        <% list(posts,function(post){ %>
            <li <%= (el)->el.data('post',post) %> class="post">
                    <%== can.route.link(post.attr('title'), {control:'posts',id:post.attr('id')},{className:'post-link'})%>
<% }) %>
</ul>
</script>
    <script  type="text/ejs" id="details">
    <h2><%= post.attr('title') %></h2>
<p><%= post.attr('content') %></p>
    </script>

JavaScript

can.fixture("/posts.json",function(){
    return [{"id":"1","title":"Welcome!","content":"This blog system is developed using Yii. It is meant to demonstrate how to use Yii to build a complete real-world application. Complete source code may be found in the Yii releases.\n\nFeel free to try this system by writing new posts and posting comments.","tags":"yii, blog","status":"2","create_time":"1230952187","update_time":"1230952187","author_id":"1"},{"id":"2","title":"A Test Post","content":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.","tags":"test","status":"2","create_time":"1230952187","update_time":"1230952187","author_id":"1"}];
});

var Post=can.Model({
        findAll : "GET /posts.json",
        findOne : "GET /posts.json/{id}",
    },{}); 


var List=can.Control({
        'init':function(element,options){
           var self=this;
                     
           can.view('main-tmpl',{posts:Post.findAll({})})
            .then(function(frag){
                self.element.html(frag);
            });
        },

        'li.post click':function(el){
            var post=el.data('post');
            can.route.attr({'id':post.id});
        }
});

var PostDetails=can.Control({
            'init':function(element,options){
                var self=this;
                can.view('details',
                    {post:Post.findOne({id:options.id})
                }).then(function(frag){
                    self.element.html(frag);
                });

            }
});


var Posts=can.Control({
    'init':function(element,options){},
    ':control/:id route':...