Skip to content

Instantly share code, notes, and snippets.

@liammclennan
Created November 5, 2010 07:15
Show Gist options
  • Save liammclennan/663767 to your computer and use it in GitHub Desktop.
Save liammclennan/663767 to your computer and use it in GitHub Desktop.
Simple Client-Side JavaScript MVC Framework
// 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