hay / stapes

the Javascript MVC microframework that does just enough
http://hay.github.io/stapes
MIT License
443 stars 54 forks source link

documentation about extend. #50

Closed flexelektro closed 10 years ago

flexelektro commented 10 years ago

the first example at http://hay.github.io/stapes/#m-extend is:

Module.extend({
    "names" : ['claire', 'alice']
    "sayName" : function(i) {
        console.log( "Hello " + this.names[i] + "!" );
    }
});

var module = new Module();
module.sayName(1); // 'alice'

apart from that there is missing a comma after the names value, this example cant run because you let call the instance the class method. Thats exactly what extend is not made for, isnt´t it ? Thats also the reason this example will not run.

I am so picky, because the documentation is the first thing you have a look at. I want use stapes for a quite large project, but if documentation lacks in these basics ...

best, felix

supermensa commented 10 years ago

You are correct. Module.proto does what the example for extend suggests:

Module.proto({
    "names" : ['claire', 'alice'],
    "sayName" : function(i) {
        console.log( "Hello " + this.names[i] + "!" );
    }
});

If you wanted to extend only the single instance, you would use instance.extend()

hay commented 10 years ago

Yes, you're right. Thanks for noticing. I fixed the example.