This uses Browserify to run the Pug compiler directly in the browser. The (source) code is very simple and can be viewed here.