electron-url

A simple way to load a file/url in electron using patterns.
Install
npm install --save electron-url
Usage
var electron = require('electron');
var electronUrl = require('electron-url');
var path = require('path');
var app = electron.app;
var BrowserWindow = electron.BrowserWindow;
electronUrl.pattern(path.join('file://' + __dirname, './{file}'));
app.on('ready', function()
{
var mainWindow = new BrowserWindow({ width: 800, height: 600 });
electronUrl.load(mainWindow, { file: 'index.html' });
});
API
.load(window, replace)
Load a file or an url on the window
.
window
A BrowserWindow
object where you want to load the url or file. Read the electron documentation for more info.
replace
An object where each key will be replaced on the url pattern with the value provided.
For example, on the following url pattern:
file://{path}/{file}.html
If you provide the following replace object:
{ "path": "my/path", "file": "test" }
The following url will be generated:
file://my/path/test.html
.pattern(value)
Set the default pattern.
value
A string with the pattern.
Related
License
MIT LICENSE © Josemi Juanes.