milo

LoadAttribute

declaration
 LoadAttribute 

milo.attributes.load
LoadAttribute class parses/validates/etc. an attribute that loads sub-views into the page.
Attribute value should be URL of the file to load subview from.
See loader for more information.

var LoadAttribute = _.createSubclass(Attribute, 'LoadAttribute', true);

####LoadAttribute instance methods####

_.extendProto(LoadAttribute, {
    attrName: attrName,
    parse: parse,
    validate: validate,
    render: render
});

module.exports = LoadAttribute;

attrName

function
 attrName() 

BindAttribute instance method that returns attribute name, by default - 'ml-load'.
To configure load attribute name use:

milo.config({ attrs: { load: 'cc-load' } }); // will set bind attribute to 'cc-load'
function attrName() {
    return config.attrs.load;
}

parse

function
 parse() 

LoadAttribute instance method that parses load attribute if it is present on the element.
It defines property loadUrl on LoadAttribute instance.
Returns the instance for method chaining.

function parse() {
    if (! this.node) return;

    this.loadUrl = this.get();
    return this;
}

validate

function
 validate() 

LoadAttribute instance method that should validate load attribute and throw if it has an invalid value.
TODO - implement url validation.
Returns the instance for method chaining.

function validate() {
    // TODO url validation
    return this;
}

render

function
 render() 

LoadAttribute instance method - returns URL

function render() {
    return this.loadUrl;
}