reru

Stupidly simple regular expression pushState router

reru

Stupidly simple regular expression pushState router.

var reru = require('reru');
 
reru(/.*/, function () {
  content.innerHTML = '';
});
 
reru('^/$', function () {
  var p = document.createElement('p');
  p.appendChild(document.createTextNode('Welcome'));
  content.appendChild(p);
});
 
reru('^/(\\d{4})$', function (year) {
  var p = document.createElement('p');
  p.appendChild(document.createTextNode('Archive for' + year));
  content.appendChild(p);
});

MIT