/**
 * @author hedgehog
 */

//	@import com.hedgehoglab.events.EventDelegator;
//	@import com.hedgehoglab.utils.Templating;
//  @import com.hedgehoglab.ui.FlashMessage;
//	@import com.hedgehoglab.application.helper.BaseHelper;
	
function BaseView(scope){
 	EventDelegator.call(this,scope);
	BaseHelper.call(this,scope);
    var _this=this;
	var _helper=this;
	
	this.generate_helpers=function(scope,argu){
        var object={};

        $.each(argu,function(i,n){
            n.call(object,scope);
        });

        return object;
    };
    this.show_flash=function(string){};

    this.cache_template=function(){
        var count=0;
        while(count<arguments.length){
            (function(e){
                setTimeout(function(){
                    TemplateTank.get_template_from_URI(e.url,function(_data){});
                },1);
            })({
                url:arguments[count]
            });

            count++;
        };

    };

    this.render_template_with_view=function(template,data,view,callback){
        TemplateTank.get_template_from_URI(template,function(_data){

			var out=Templating.parseTemplate({
                data:data,
                view:view,
                template:_data
            });
            callback(out);
        });
    };

    this.render_template_from_html=function(template,data,view,callback){
        callback(Templating.parseTemplate({
            data:data,
            view:view,
            template:TemplateTank.parse_template(template)
        }));
    };

    this.render_partial=function(name,model){
        var tmp="";
// console.warn(_this);
        _this.render_template_with_view(name,model,_helper,function(f){
            tmp=f;
        });
        return tmp;
    };
};
