HTML Template


#1

Hey guys,

on Django I can load a template file in this way:
{% extends ‘my_template.html’ %}

And in this way I have a base/template HTML file and I can add content inside blocks

{ block main_content } // for example

Can I do it using Electron ? what’s the right way to use HTML templates ?


#2

Electron doesn’t do it itself, but you could render your templates in a similar way with any of the Mustache-like libraries (Handlebars, Hogan, etc) as if your main.js was a server, or use something ‘client-side’ such as an MVC-like JS framework (Vue, React, Angular, etc)

There are endless ways to do what you’re looking to do, but so many ways that it really depends what your needs are. I’d suggest doing something “client-side”, as an app feels more app-y if it behaves as a single page application, rather than loading pre-rendered pages. Fundamentally though, any JavaScript library that achieves this would be suitable/workable for templating HTML in an Electron app.