Skip to content
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

[Feature] Add preprocessor support #13

Closed
thetutlage opened this issue Nov 10, 2017 · 7 comments
Closed

[Feature] Add preprocessor support #13

thetutlage opened this issue Nov 10, 2017 · 7 comments
Assignees
Labels
Priority: Medium Try to fix the issue for the next patch/minor release Type: Enhancement Improving an existing feature
Milestone

Comments

@thetutlage
Copy link
Member

From @watzon on November 8, 2017 21:15

Laravel gives us the ability to have blade templates that take blade/markdown and turn it into an HTML email template. This saves some major headache when it comes to making emails beautiful and responsive. It would be awesome if Adonis had the same functionality.

Proposal

Add a markdown method to the Mailer and some built in components that get added to edge templates. Developers should ideally be able to use the markdown method to render an edge template, or send plain markdown which will be parsed into valid email HTML before being sent.

Example Code

<!-- resources/views/emails/shipped.edge -->

@component('mail.message')
# Order Shipped

Your order has been shipped!

@component('mail.button', url = {{ order.viewUrl }})
View Order
@endcomponent

Thanks,<br>
{{ Config('appName') }}
@endcomponent
// app/Controllers/Http/OrdersController.js

await Mail.markdown('emails.shipped', Order.toJSON(), (message) => {
  message.subject('Hello ...')
  message.from('foo@bar.com')
  message.to('baz@bar.com')
})

Reference

https://laravel.com/docs/5.5/mail#markdown-mailables
https://www.npmjs.com/package/markdown
https://www.npmjs.com/package/markdown-it

Copied from original issue: adonisjs/mail#15

@thetutlage thetutlage added Priority: Medium Try to fix the issue for the next patch/minor release Status: Pending Type: Enhancement Improving an existing feature labels Nov 10, 2017
@thetutlage
Copy link
Member Author

From @RomainLanz on November 8, 2017 21:33

Hey @watzon! 👋

I don't think adding a built-in Markdown support is a great idea. This would mean we choose to use Markdown over other simple text engine (like Asciidoc - that we heavy use in our documentation).

Why not make the MailSender class Macroable so you could add methods to it and handle this with a community package? This will avoid Adonis to take a strong decision and let the developer choose the tool he wants to use.

Concerning the idea of having built-in components I also think it'd be better to have a community package that handles that.

Then you could simply install it and use it with a syntax like the code below.

@component('@myPackage::mail.button', url = {{ order.viewUrl }})
  View Order
@endcomponent

(A similar syntax was proposed on the 4.0 Roadmap - section adonis-translator (new))

@thetutlage
Copy link
Member Author

From @watzon on November 8, 2017 21:36

@RomainLanz I think making the MailSender class Macroable would be a fine idea. If a community package could handle this then that would work as well.

@thetutlage
Copy link
Member Author

From @RomainLanz on November 8, 2017 21:40

Also, using community package instead of having built-in components will let the community create many packages with many designs (Material, Bootstrap, Foundation, Semantic-UI, etc.).

Same goes for MailSender that will be able to handle other templating like MJML or Foundation Email.

@thetutlage
Copy link
Member Author

From @watzon on November 8, 2017 21:42

I like that idea

@thetutlage
Copy link
Member Author

From @RomainLanz on November 8, 2017 22:13

Cool, let's wait to see the opinion of @thetutlage on this.

@thetutlage
Copy link
Member Author

So Adonis mail doesn't have any idea on how the view engine works, it just uses Edge. My plan is to let users add preprocessors to Edge, so it will be like this

Raw edge

const edge = require('edge.js')
edge.use('mail/*.edge', function (content) {
  // return parsed content
})

In Adonis

const View = use('View')
View.use('mail/*.edge', function (content) {
  // return parsed content
})

@thetutlage thetutlage self-assigned this Nov 10, 2017
@thetutlage thetutlage changed the title [Feature] Add ability to use markdown templates [Feature] Add preprocessor support Nov 10, 2017
@thetutlage thetutlage added this to the 2.0 milestone May 23, 2018
@thetutlage
Copy link
Member Author

Idea dropped. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Try to fix the issue for the next patch/minor release Type: Enhancement Improving an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant