Did you ever feel like forgetting all about html markup and using markdown instead, inside a play template?
@md {
It is really simple to **include markdown text** in a *play template*, using the [common-mark](https://github.com/atlassian/commonmark-java) parser:
- it's simple
- it's fast
}
It's pretty simple, here's a one-file solution, using the awesome common-mark parser. You'll need first of all a play template called md.scala.html
:
@(f: =>Html)
@Html(
org.commonmark.renderer.html.HtmlRenderer.builder().build().render(
org.commonmark.parser.Parser.builder().build().parse(f.toString))
)
And then, in your build.sbt
or Build.sbt
, you'll have to include the common mark parser, the fastest and bestest:
"com.atlassian.commonmark" % "commonmark" % "0.7.0",
... and that's all, folks.
Of course, perhaps a better solution is to have all your templates be markdown, so of the form mytemplate.scala.markdown
but for the most part, I find that plain html with embedded markdown text works well.
p.s. This entire website is markdown.