Laravel 5.4 wrongly mix HTML components in Markdown Mailable

痞子三分冷 提交于 2019-12-05 17:16:08

问题


I had ordinary Mailable that had some hardcoded content.

I've published mailable views, changed content to markdown and replaced ->view with ->markdown.

Now mail have nicely formated markdown.

However Laravel after compiling that markdown will pick HTML component definitions, for reasons I can not phantom. And that after it used Markdown version for message, so it's mixing both kinds in a single Mailable markdown view!

I've tried:

  • php artisan cache:clear
  • php artisan view:clear
  • adding markdown to html components - wont work, Laravel use them past markdown compilation step
  • changing ->markdown to ->markdown - yes it will give error about unexisting method

Using: PHP 7.0, Laravel 5.4.28

Q: Is there any Laravel global setting that would override ->markdown call? Any other ideas what may be wrong?


回答1:


Re reading the docs:

Markdown mailables support Blade templates. Blade support only ordinary html and blade syntax.

Individual components can use markdown compilers to parse some or all inputs. That's how @component('mail::table') works.

Update: Markdown versions are used to generate plain text mails. Where as blade templates are used to generate html versions. Again, markdown can be compiled explicitly in blade templates, but that's the extend of it's support.




回答2:


I think you need to follow laravel documentation here:https://laravel.com/docs/5.4/mail#markdown-mailables and also you could check laravel news article https://laravel-news.com/laravel-markdown-emails.



来源:https://stackoverflow.com/questions/45828322/laravel-5-4-wrongly-mix-html-components-in-markdown-mailable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!