
var Tpl = {
    
    parse : function(tplHtml, dataHash)
    {
        try
        {
        	var html = tplHtml;
        	
            for (var k in dataHash)
            {
            	var subst = dataHash[k];
            	
                html = html.replace( (new RegExp('#\\{'+k+'\\}','g')), subst );
            }
            
            return html;
        }
        catch(e)
        {
            console.log('template.parse(); exception: ' + e);
        }
    },

    loop : function(tplItem, tplData, length)
    {
        try
        {
            var _list = '';
            
            for (var i = 0; i < length; i++) 
            {
                _list += Tpl.parse(tplItem, tplData[i]);
            }
            
            return _list;
        }
        catch(e)
        {
            console.log('template.loop(); exception: ' + e);
        }
    }
}