var app = new Dean.Application('#main', function() {
this.options({
base: '#!/',
throw_errors: false
});
// executed before each route dispatch
this.before(function() {
// write the current route into an element, cause we can't see it in the url bar
var bar = document.getElement('div#location span.hash');
bar.set('text', window.location.hash);
// clear the page body
this.clear();
});
this.get('#!/', function() {
new Element('div', {text: 'Simple Page'}).inject(this.getElement());
});
// Mustache Plugin
this.use(Dean.Template.Mustache);
this.get('#!/mustache', function() {
var html = this.mustache('<b>Mustache: You have a nice beard, {{name}}!</b>', {name: 'Dude'});
new Element('div', {html: html}).inject(this.getElement());
});
// YQL Plugin with Mustache flavour
this.use(Dean.Service.YQL);
this.use(Dean.Template.Mustache);
this.get('#!/yql', function() {
this.yql('SELECT id, name, url from music.artist.similar WHERE id="306489" LIMIT 5', function(response) {
var tpl = "<h3>Artists simliar to Alexisonfire (pulled with YQL)</h3>" +
"<ul> {{#Artist}}<li>" +
"<a href=\"{{url}}\" target=\"_blank\">{{name}}</a>" +
"</li>{{/Artist}} </ul>";
var html = this.mustache(tpl, response.query.results);
new Element('div', {html: html}).inject(this.getElement());
}.bind(this));
});
});
app.run();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.