$(function(){
	//$('body').ajaxError(function(e,xhr,settings,exception){ alert(JSON.stringify(exception)) });
	$('.news-list')
	.each(function() {
		var $div = $(this), cfg, $ul;
		cfg = $.parseJSON($div.attr('cfg'));
		$.getJSON(cfg.url,{},function(d,s){
			$.each(d.data,function(i,obj){
				var html = String(cfg.fmt);
				$.each(obj,function(n,v){ html = html.replace(new RegExp('\\{' + n + '\\}','ig'),v); });
				if (!$ul) $ul = $('<ul/>');
				$ul.append($('<li/>').html(html));
			});
			if ($ul) $div.replaceWith($ul);
		});
	});
});
