/*
config = {
    
    title: "Test Title",
    modules: {
        
        'idOfDomElement1': "miid",
        'idOfDomElement2': "miid"
    },
    source: {
    
        name: "operationName",
        path: "",
        data: {}
    },
    bind: [BIND_OBJECT]
}
*/
"use strict";

define(["github/adioo/bind/v0.1.1/bind"], function(bind) {
    
    return function(config) {
        
        var target = this && this.dom ? this.dom : document;
        
        //load modules
        if (config.modules) {
            
            for (var selector in config.modules) {
                
                M(target.querySelector("#" + selector), config.modules[selector]);
            }
        }
        
        //set document title
        if (config.title) {
            
            document.title = config.title;
        }
        
        //bind data
        if (config.data) {
            
            bind.call(this, config.data, null, target);
        }
        
        if (config.source) {
            
            this.link(config.source, function(err, result) {
                
                if (!err && result) {
                    
                    bind(result, null, target);
                }
            });
        }
    };
});

@@ -438,32 +438,1634 @@
 ument;%0A        %0A
+        // load css%0A        if (config.css) %7B%0A            %0A            // get head reference%0A            var head = document.getElementsByTagName(%22head%22)%5B0%5D;%0A            %0A            for (var i in config.css) %7B%0A                %0A                var href;%0A                %0A                if (config.css%5Bi%5D.indexOf(%22http%22) %3E -1) %7B%0A                    %0A                    href = config.css%5Bi%5D;%0A                %7D%0A                else %7B%0A                    %0A                    href = this.ok + %22/core/getFile%22 + (config.css%5Bi%5D%5B0%5D == %22/%22 ? %22%22 : %22/%22) + config.css%5Bi%5D%0A                %7D%0A                %0A                // create link and append it to the DOM%0A                var link = document.createElement(%22link%22);%0A                var attributes = %7B%0A                        rel:    %22stylesheet%22,%0A                        type:   %22text/css%22,%0A                        href:   href%0A                    %7D;%0A                    %0A                for (var name in attributes) %7B%0A                    %0A                    link.setAttribute(name, attributes%5Bname%5D);%0A                %7D%0A                %0A                head.appendChild(link);%0A            %7D%0A        %7D%0A        %0A        if (config.html && target) %7B%0A            %0A            // create module container%0A            var container = document.createElement(%22div%22);%0A            %0A            // add miid to html%0A            container.setAttribute(%22id%22, this.miid);%0A            %0A            // add html%0A            container.innerHTML = config.html;%0A            %0A            // append module to the dom%0A            target.appendChild(container);%0A        %7D%0A        %0A
         //load m

load css and render html