1

I am experimenting with Electron and attempting to use EJS for layouts and partials. I can not get it to work trying the instructions here and can not find anything better. I am new to node and it all seems a bit overly complex to setup. It makes me wonder whether I should be using EJS and templates for native app development in the first place..?

Dionysis
  • 804
  • 8
  • 25
  • Can you not use Express and Express#Router to render the EJS templates with a context? You could then just open links with your buttons, but the user would never see the link. – Joshua Aug 07 '17 at 07:38
  • @Crowes I could.. but this approach feels like a hack for a desktop app. I am just wondering about common ways of achieving this kind of functionality. – Dionysis Aug 13 '17 at 09:47
  • Hack? Electron is ECF with Node, so a browser. You're running websites inside the `BrowserWindow`` you instantiate. using Express, Angular, or Vue routing would not be a hack. – Joshua Aug 21 '17 at 07:16
  • @Crowes Articles like [this](https://blog.samuelattard.com/using-express-inside-electron/) confused me. That is why I am asking for common strategies to get a sense of what other people are doing. – Dionysis Aug 21 '17 at 08:10
  • The `electron-router` package mentioned seems to be a good call. – Joshua Aug 21 '17 at 09:17

1 Answers1

4

install ejs-electron using npm install ejs-electron and import ejs-electron in main window page like

const ejse = require('ejs-electron')

and use your ejs page like

mainWindow.loadFile('client/components/home/index.ejs')

use constant ejse if you want but it is necessary to install and import ejs-electron if you want ejs as atemplate. you can follow the link ejs-electron