Giter VIP home page Giter VIP logo

mad's Introduction

MAD

Modular Application Development

Examples

You can clone or download them from mad-examples

module.json

The very existence of this file (even if empty) defines the current directory as a module.

Here are some of the settings you can use to define the behavior of your modules.

{
    // Is the unique (or global) identifier of the module.
    "id": "module_name"
    
    // Contains the specifications about how the resources of this module should be handled.
    "resources": {

        // Enables cache only for the specified resources.
        // By default nothing is cached.
        "cache": {
            // cache the content of module.js file
            "module": true,
            
            // cache all templates
            "templates": true
            
            // cache specific files
            "templates": ["dashboard"]
            
            // the same applies for [styles] and [components]
        },
        
        // Defines which resources are sent when the module is requested. (Don't panic! you can request individual resources later on)
        "required": {
            // If undefined, all [templates] will be sent.
            // In this case just the template "login.html" will be sent.
            // Note that you don't have to specify the file extension in the template name.
            "templates": ["login"]
            
            // the same applies for [styles] and [components]
        }
    }
}

module.js

This is where you define the behavior of your module, set event handlers, etc.

    function module( shared ) {
        var module = this;
        var resources = module.resources;
        
        module.initialize = function () {
            // accessing resources
            var html = resources.templates[ "login" ];
            
            // the style section contain references to the <style> tags instead of the actual css code
            // all styles are inserted to the DOM automatically 
            var css = resources.styles[ "login" ];
            
            document.body.innerHTML = html;
            
            // access shared/global resources like this (considering it was loaded previously)
            var more_html = shared.resources.templates["generic-view"];
            
            // request data on the fly
            resources.get( { templates: ['lazy-load'] }, function( exception ) {
                if( exception ){
                    throw 'BOOM!';
                }
                
                var even_more_html = this.templates['lazy-load'];
            });
        }
    }

mad's People

Contributors

carlosjln avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.