Skip to content

[Feature] Implement a notification template engine #2105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexjustesen opened this issue Mar 19, 2025 · 3 comments
Open

[Feature] Implement a notification template engine #2105

alexjustesen opened this issue Mar 19, 2025 · 3 comments
Assignees
Labels
feature New feature or request

Comments

@alexjustesen
Copy link
Owner

alexjustesen commented Mar 19, 2025

📃 Description

Starting to think about a templating engine so that the body and/or subject of a notification can be customized from within the UI.

Important

This is just a brain dump of thoughts there is no ETA on this feature and it could be killed off if I think the juice isn't worth the squeeze.

👀 Resources

Practical options

Parse markdown content

This method translates the string to the given values and then parses the markdown to HTML.

use App\Models\Result;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

public function parseBody(Result $result)
{
    // Get the sample markdown to simulate user-driven content
    $contents = Storage::get('sample_body.md');

    // Translate the file contents
    $output = strtr($contents, [
        '{$id}' => $result->id,
        '{$download}' => $result->download,
        '{$upload}' => $result->upload,
        '{$ping}' => $result->ping,
    ]);

    echo Str::markdown($output, [
        'allow_unsafe_links' => false,
        'html_input' => 'strip',
        'max_nesting_level' => 5,
    ]);
}
# Speedtest Tracker Result

- Result: {$id}
- Download: {$download}
- Upload: {$upload}
- Ping: {$ping}
- Invalid: {$invalid}

Image

@alexjustesen alexjustesen added the feature New feature or request label Mar 19, 2025
@alexjustesen alexjustesen self-assigned this Mar 19, 2025
@jigar-dhulla
Copy link

I hope I have understood the requirement correctly.

Just thinking out loud. Are users comfortable in sharing MJML template instead of markdown?

MJML has good tooling, I am sure there are good builders where users can generate template easily and share it with you. Like https://www.mjmliquid.com/editor

Then just like Blade, you can inject your values in the template.

@alexjustesen
Copy link
Owner Author

@jigar-dhulla so in this instance it isn't just the mail notification channel which is why I was trying to find something that wasn't mail specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants