Lawrence Dawson
Lawrence Dawson

Reputation: 113

Save Laravel 5.4 Markdown Templates to, and retrieve from, database

I'm developing an app that needs to have the ability for users to create custom email templates and also send them built into it.

I like the look of the Laravel 5.4 markdown templates, I could take care of the syntax generation in the front end, and then would ideally like to be able to save them to a database table so that they can be easily maintained by users in the future rather than developers.

So far I have built functionality to save a string containing a markdown template, retrieve it, and pass that string into an emails build() function.

However, I cannot for the life of me find a resource online that can advise how to render that template string correctly in a blade.

Is this even possible?

Any help would be greatly appreciated, I've been coding for less than a year and using Laravel for less than 6 months so apologies if my question is a little amateur or nondescript.

Upvotes: 1

Views: 756

Answers (1)

Nerea
Nerea

Reputation: 2157

I'm using this to render Markdown

https://github.com/thephpleague/commonmark

So you can do {!! (new \League\CommonMark\CommonMarkConverter())->convertToHtml($source) !!} where $source is your database data.

Hope it helps

Upvotes: 2

Related Questions