Passing raw Markdown text to Jade

后端 未结 4 1277
栀梦
栀梦 2021-02-02 09:57

I\'m playing around with my first Node.js Express application, and as every programmer knows, the first thing you should build when testing out a new framework is a blog! Anyway

4条回答
  •  再見小時候
    2021-02-02 10:33

    I don't think jade can do this out of the box. One way to accomplish it that might feel slightly cleaner than pre-rendering the markdown is to create a helper function called markdown that takes a markdown string and returns HTML. Then you could do something like

    section
        != markdown(md)
    

    The markdown function should be included in the locals data when you render the jade template and can directly use a markdown library to convert the markdown syntax to HTML.

提交回复
热议问题