public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-docs] notifications: add section about how to use custom templates
@ 2025-04-09  7:47 Lukas Wagner
  2025-04-09  7:56 ` Alexander Zeidler
  2025-04-09  8:10 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Lukas Wagner @ 2025-04-09  7:47 UTC (permalink / raw)
  To: pve-devel

This section is meant to give a basic overview on how to use
custom templates for notifications. It will be expanded in the
future, providing a more detailed view on how templates are resolved,
existing fallback mechanisms, available templates, template
variables and helpers.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 notifications.adoc | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/notifications.adoc b/notifications.adoc
index 331ac1d..0b0311b 100644
--- a/notifications.adoc
+++ b/notifications.adoc
@@ -462,3 +462,28 @@ to `auto`.
 
 The `legacy-sendmail` mode might be removed in a later release of
 {pve}.
+
+Overriding Notification Templates
+---------------------------------
+
+{pve} uses Handlebars templates to render notifications. The 
+original templates provided by {pve} are stored in
+`/usr/share/pve-manager/templates/default/`.
+
+Notification templates can be overridden by providing a custom template
+file in the override directory at `/etc/pve/notification-templates/default/`.
+When rendering a notification of a given type, {pve} will first attempt
+to load a template from the override directory. If this one does not
+exist or fails to render, the original template will be used.
+
+The template files follow the naming convention of
+`<type>-<body|subject>.<html|txt>.hbs`. For instance, the file
+`vzdump-body.html.hbs` contains the template for rendering the HTML version
+for backup notifications, while `package-updates-subject.txt.hbs` is used to
+render the subject line of notifications for available package updates.
+
+Email-based notification targets, such as `sendmail` and `smtp`, always send
+multi-part messages with an HTML and a plain text part. As a result, both
+the `<type>-body.html.hbs` as well as the `<type>-body.txt.hbs` template
+will be used when rendering the email message. All other notification
+target types only use the `<type>-body.txt.hbs` template.
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH pve-docs] notifications: add section about how to use custom templates
  2025-04-09  7:47 [pve-devel] [PATCH pve-docs] notifications: add section about how to use custom templates Lukas Wagner
@ 2025-04-09  7:56 ` Alexander Zeidler
  2025-04-09  8:10 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Zeidler @ 2025-04-09  7:56 UTC (permalink / raw)
  To: Proxmox VE development discussion

On Wed Apr 9, 2025 at 9:47 AM CEST, Lukas Wagner wrote:
> This section is meant to give a basic overview on how to use
> custom templates for notifications. It will be expanded in the
> future, providing a more detailed view on how templates are resolved,
> existing fallback mechanisms, available templates, template
> variables and helpers.
>
> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>

Reviewed-by: Alexander Zeidler <a.zeidler@proxmox.com>

> ---
>  notifications.adoc | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/notifications.adoc b/notifications.adoc
> index 331ac1d..0b0311b 100644
> --- a/notifications.adoc
> +++ b/notifications.adoc
> @@ -462,3 +462,28 @@ to `auto`.
>  
>  The `legacy-sendmail` mode might be removed in a later release of
>  {pve}.
> +
> +Overriding Notification Templates
> +---------------------------------
> +
> +{pve} uses Handlebars templates to render notifications. The 
> +original templates provided by {pve} are stored in
> +`/usr/share/pve-manager/templates/default/`.
> +
> +Notification templates can be overridden by providing a custom template
> +file in the override directory at `/etc/pve/notification-templates/default/`.
> +When rendering a notification of a given type, {pve} will first attempt
> +to load a template from the override directory. If this one does not
> +exist or fails to render, the original template will be used.
> +
> +The template files follow the naming convention of
> +`<type>-<body|subject>.<html|txt>.hbs`. For instance, the file
> +`vzdump-body.html.hbs` contains the template for rendering the HTML version
> +for backup notifications, while `package-updates-subject.txt.hbs` is used to
> +render the subject line of notifications for available package updates.
> +
> +Email-based notification targets, such as `sendmail` and `smtp`, always send
> +multi-part messages with an HTML and a plain text part. As a result, both
> +the `<type>-body.html.hbs` as well as the `<type>-body.txt.hbs` template
> +will be used when rendering the email message. All other notification
> +target types only use the `<type>-body.txt.hbs` template.



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH pve-docs] notifications: add section about how to use custom templates
  2025-04-09  7:47 [pve-devel] [PATCH pve-docs] notifications: add section about how to use custom templates Lukas Wagner
  2025-04-09  7:56 ` Alexander Zeidler
@ 2025-04-09  8:10 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2025-04-09  8:10 UTC (permalink / raw)
  To: pve-devel, Lukas Wagner

On Wed, 09 Apr 2025 09:47:13 +0200, Lukas Wagner wrote:
> This section is meant to give a basic overview on how to use
> custom templates for notifications. It will be expanded in the
> future, providing a more detailed view on how templates are resolved,
> existing fallback mechanisms, available templates, template
> variables and helpers.
> 
> 
> [...]

Applied, thanks!

[1/1] notifications: add section about how to use custom templates
      commit: 56f3d84b753eaff2b8a6d421fcb34b38b3b5e963


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-09  8:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-09  7:47 [pve-devel] [PATCH pve-docs] notifications: add section about how to use custom templates Lukas Wagner
2025-04-09  7:56 ` Alexander Zeidler
2025-04-09  8:10 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal