javascript - How to render Jade in Electron? -
in express
possible set view engine
jade
following code:
app.set('view engine', 'jade');
so, allows express
read , return compiled html
jade
files directly.
how can in electron
?
i built small module intercept jade
protocols , compile ending .jade
, rest considered local files. use in main file following:
'use strict'; var app = require('app'); var locals = {/* ...*/}; var j = require('electron-jade')({pretty: true}, locals); var browserwindow = require('browser-window'); // standard stuff app.on('ready', function () { mainwindow = new browserwindow({ width: 800, height: 600 }); mainwindow.loadurl('jade://' + __dirname + '/index.jade'); // rest... });
note instead of file://
write jade://
.
disclaimer: module in stages , logic still not mature enough.
update:
i published package on npm: https://www.npmjs.com/package/electron-jade
Comments
Post a Comment