Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 18, 2014 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/2d1d4befd9d6e97859a7 to your computer and use it in GitHub Desktop.
Save devdays/2d1d4befd9d6e97859a7 to your computer and use it in GitHub Desktop.
Single Page Apps - Sammy + Mustache
<script src="Scripts/jquery-2.0.2.js"></script>
<script src="Scripts/mustache.js"></script>
<script src="Scripts/sammy-0.7.4.js"></script>
<script src="Scripts/sammy.mustache.js"></script>
<script>
var app = $.sammy(function() {
// include the plugin and alias mustache() to ms()
this.use('Mustache', 'ms');
// to see this you will need to go to
// yourpage#/hello/AName
this.get('#/hello/:name', function() {
// set local vars
this.title = 'Hello!'
this.name = this.params.name;
// render the template and pass it through mustache
this.partial('mytemplate.ms');
});
});
$(function() {
app.run()
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment