Skip to content

Instantly share code, notes, and snippets.

@grimmdev
Created December 20, 2017 17:24
Show Gist options
  • Save grimmdev/2f1ea60310d691c8668fe0a0313db0d2 to your computer and use it in GitHub Desktop.
Save grimmdev/2f1ea60310d691c8668fe0a0313db0d2 to your computer and use it in GitHub Desktop.
Electron and PUG
// Was able to piece the solution together using several answers from separate topics.
// Pretty simple function, passes in the window you want to use pug files and renders it
function RenderPUG(win, page)
{
let h = 'data:text/html;charset=utf-8,' + encodeURI(pug.renderFile(page))
win.loadURL(h)
}
// Example RenderPUG(mainWindow, 'views/index.pug')
@NeoTheThird
Copy link

Souldn't it actually be encodeURIComponent? encodeURI does not cover everything: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment