Passing raw Markdown text to Jade

后端 未结 4 1286
栀梦
栀梦 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:44

    You can do this with a function passed in to jade from node:

    var md = require("node-markdown").Markdown;
    

    Then pass it into the view as a local:

    res.render('view', { md:md, markdownContent:data });
    

    Then render it in the jade view by calling the function:

    != md(markdownContent)
    

提交回复
热议问题