Created
November 5, 2010 07:15
-
-
Save liammclennan/663767 to your computer and use it in GitHub Desktop.
Simple Client-Side JavaScript MVC Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// full source is at https://github.com/liammclennan/Client-Side-JavaScript-MVC-Framework | |
// framework makes available two global variables: app and views | |
// Step 1: Define views. If a requested view is not defined then the framework gets the template from /views/[viewname] | |
views.welcome = function() { | |
var template = " \n\ | |
#container \n\ | |
%ul \n\ | |
%li= name \n\ | |
"; | |
return template; | |
}; | |
// Step 2: Define actions | |
app.get('#one/:name', function(name) { | |
app.render({ | |
target: '#menu_div', | |
viewName:'welcome', | |
data: {name: 'Liam'} | |
}); | |
}); | |
// Step 3: A 'request' calls... | |
app.request('#one/Liam'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment