<div id="demo"></div>
<script type="text/javascript">
YUI().use("widget", "gallery-widget-io", "json-parse", "escape", function(Y) {

    var formatRSS = function (val) {
        var formatted = "Error parsing feed data";
        try {
            var json = Y.JSON.parse(val);

            if (json && json.count) {
                var html = ['<ul class="yui3-feed-data">'];
                var linkTemplate = '<li><a href="{link}" target="_blank">{title}</a></li>';

                Y.each(json.value.items, function(v, i) {
                    if (i < 10) {
                        v.title = Y.Escape.html(v.title);
                        v.link = Y.Escape.html(v.link);
                        html.push(Y.Lang.sub(linkTemplate, v));
                    }
                });
                html.push("</ul>");
                formatted = html.join("");
            } else {
                formatted = "No Data Available";
            }
        } catch(e) {
            formatted = "Error parsing feed data";
        }
        return formatted;
    };

    Y.on('io:xdrReady', function() {

        var widget = new Y.Widget();

        widget.plug(Y.Plugin.WidgetIO, {
            uri : 'http:/' + '/pipes.yahooapis.com/pipes/pipe.run?_id=6b7b2c6a32f5a12e7259c36967052387&_render=json&url=http:/' + '/rss.news.yahoo.com/rss/us',
            cfg:{
                xdr: {
                    use:'flash'
                }
            },
            formatter: formatRSS,
            loading: '<img class="yui3-loading" width="32px" height="32px" src="{{componentAssets}}/img/ajax-loader.gif">'
        });
        widget.render('#demo');

        widget.io.refresh();
    });

    Y.io.transport({
        id:'flash',
        yid: Y.id,
        src:'io.swf?stamp=' + (new Date()).getTime() //Relative path to the .swf file from the current page.
    });

});
</script>
