JSFiddle - React, Tailwind, and code Playground

by ericf

HTML

<script src="http://yui.yahooapis.com/3.5.0pr4/build/yui/yui-min.js"></script>

JavaScript

YUI().use('model', 'view', function (Y) {

    Y.Post = Y.Base.create('post', Y.Model, []);
    
    Y.PostView = Y.Base.create('postView', Y.View, [], {
        textTemplate: '<strong>{title}</strong>',
        imgTemplate : '<em>{title}</em>',
        
        render: function () {
            var post     = this.get('post'),
                template = post.get('type') === 'img' ? this.imgTemplate : this.textTemplate;
            
            this.get('container').setContent(Y.Lang.sub(template, {title: post.get('title')}));
            
            return this;
        }
    });
    
    var textPost = new Y.Post({type: 'text', title: 'A Text Post'}),
        imgPost  = new Y.Post({type: 'img', title: 'An Image Post'});
    
    new Y.PostView({post: textPost}).render().get('container').appendTo('body');
    new Y.PostView({post: imgPost}).render().get('container').appendTo('body');

});