Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/knpwrs/electron-handlebars
Use Handlebars instead of plain HTML for your Electron apps!
https://github.com/knpwrs/electron-handlebars
Last synced: about 2 months ago
JSON representation
Use Handlebars instead of plain HTML for your Electron apps!
- Host: GitHub
- URL: https://github.com/knpwrs/electron-handlebars
- Owner: knpwrs
- License: mit
- Created: 2016-09-14T02:10:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-07T20:30:17.000Z (over 7 years ago)
- Last Synced: 2024-09-17T20:09:57.317Z (4 months ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 8
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-handlebars
[![Greenkeeper badge](https://badges.greenkeeper.io/knpwrs/electron-handlebars.svg)](https://greenkeeper.io/)
Use [Handlebars] instead of plain HTML for your [Electron] app!
## Usage
In your main process JavaScript:
```js
const { app, BrowserWindow } = require('electron');require('electron-handlebars')({
// Template bindings go here!
title: 'Hello, World!',
body: 'The quick brown fox jumps over the lazy dog.',
});let mainWindow = null;
app.on('window-all-closed', () => app.quit());
app.on('ready', () => {
mainWindow = new BrowserWindow({
show: false,
width: 400,
height: 300,
});
mainWindow.loadURL(`file://${__dirname}/index.hbs`);
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.show();
mainWindow.focus();
});
});
```And in `index.hbs` (or whatever other file you are loading with `loadURL`):
```hbs
{{ title }}
{{ title }}
{{ body }}
```
## Example App
There is a complete (albeit small) working example app in the `example`
directory. You can run it from *root* directory with the following:```sh
npm i
npm start
```## Similar Projects
This library was inspired by the following:
* [`electron-pug`]
* [`electron-ejs`]## License
**MIT**
[Electron]: http://electron.atom.io/ "Electron"
[Handlebars]: http://handlebarsjs.com/ "Handlebars.js"
[`electron-ejs`]: https://github.com/jmjuanes/electron-ejs "electron-ejs"
[`electron-pug`]: https://github.com/yan-foto/electron-pug "electron-pug"