Git Product home page Git Product logo

electron-pug's Introduction

electron pug

This module is a simple file protocol interceptor for electron which compiles all (local) URLs to files with .pug extension (e.g /home/electron-pug/index.pug) on the fly.

Neutron Compatible NPM Version license

Installation

npm install electron-pug

Usage

Just initialize this module with desired options for Pug package and your locals:

'use strict';

const {app, BrowserWindow} = require('electron')
const locals = {/* ...*/}
const setupPug = require('electron-pug')

// Standard stuff

app.on('ready', async () => {
  try {
    let pug = await setupPug({pretty: true}, locals)
  } catch (err) {
    // Could not initiate 'electron-pug'
  }

  let mainWindow = new BrowserWindow({ width: 800, height: 600 })

  mainWindow.loadURL(`file://${__dirname}/index.pug`)
  // the rest...
})

Endorsements

Here is a list of all projects (known to me) who have silently endorsed this project (or its predecessor) by copying the source code without attribution: yet-another-electron-pug, electron-nunjucks, wfo-app, demetra-aplikacija, electron-twig, FreeFrontiers-App, electron-posthtml, and many other that I failed to track down!

Even more!

If you want to have least effort when developing electron packages, take a look at neutron!

electron-pug's People

Contributors

allcapsc avatar norman784 avatar paulll avatar yan-foto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

electron-pug's Issues

Pug function problem!

Following error comes when loading pug file:

Error: the "basedir" option is required to use includes and extends with "absolute" paths

Can not initialize protocol module before app is ready

Hi,

since last update of electron-pug, my app stopped working, it always ends with the error message mentioned in title. It was working before, when I was using the 1.3.0 version. The longer error is shown in image below. As you can see, it mentions the electron-pug module. Can you please help me?

screen shot 2016-05-20 at 10 48 29

Pug and i18n

Hi, I can't get i18n to work in pug files loaded by electron-pug. Is this module supposed to be able to translate i18n strings in pug files? Is there a specific way to make it work?

Spaces in file names and paths cause errors

Since the getPath function uses the parse() method of the URL library, it will convert spaces in file paths to %20. When fs.readFileSync receives the modified file name, it will fail to load the file properly which throws an error.

While this probably isn't an issue on *Nix machines, on Windows, where an Electron App would be installed in 'Program Files' or 'Program Files (x86)', it becomes an issue.

ProtocolDeprecateCallback: The callback argument of protocol module APIs is no longer needed.

Using electron v20.0.3 with node v16.17.0, I get the following warning when loading a pug file:
ProtocolDeprecateCallback: The callback argument of protocol module APIs is no longer needed.

The pug file loads just fine but it would be great to know where this comes from.
I'm using the following code to load a pug file:

    win.loadFile('./static/html/test.pug', {
      query: {'data': JSON.stringify(data)}
    });   

And here is my pug setup code

    app.whenReady().then(async () => {
        try {  
            let pug = await setupPug({pretty: true})  
            pug.on('error', err => console.error('electron-pug error', err))  
        } catch (err) {  
            console.log(err);  
        }  
    }).then(initApp);  

When I remove the electron-pug setup code above, the warning disappears. The pug file is still loaded but obviously the pug code is not interpreted (displayed as plain text).

Any idea of why this warning is showing?
Great app, thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.