groue / GRMustache

Flexible and production-ready Mustache templates for MacOS Cocoa and iOS
http://mustache.github.com/
MIT License
1.44k stars 190 forks source link

Markdown Support #105

Closed davecom closed 8 years ago

davecom commented 8 years ago

This is more a "want to have" - but it would be incredible if with HTML templates there was the ability to auto-parse Markdown. For example if I have <p> {{ dog }} </p> in my template and dog contains a String which is in Markdown then the output in the template would be translated into HTML. Right now I'm planning to string together GRMustache with MMMarkdown via a Formatter or Rendering Object. Is that the best way to solve this issue?

groue commented 8 years ago

Hello @davecom. GRMustache will not have built-in support for markdown.

The simplest solution is to prepare your input, feed your templates with HTML generated by markdown, and use triple-mustache tags {{{ dog }}} to avoid escaping of this HTML.

A more involved solution could use, as you say, filters ({{ markdown(dog) }}) that return rendering objects (in order to explicitly manage the HTML content type) but I must first advise the simplest solution above.

davecom commented 8 years ago

Thanks for the reply and thanks for making a great library.