2015년 1월 6일 화요일

Re: [Express-js] Jade: Pass markdown filter a variable.

FYI: `github-flavored-markdown` is now deprecated. Use `marked` instead.

https://github.com/chjj/marked

On Sunday, March 4, 2012 8:19:29 AM UTC-6, Paul wrote:
That's the only solution I was able to find, too, though in my case I made it a view helper and called it from the view:

app.helpers({ md : function(text){
   return ghm.parse(text);
}});

div != md(content.body)

On Sun, Mar 4, 2012 at 9:00 AM, Brandon Martin<bma...@zyphmartin.com> wrote:
Sorry I was trying to make it more generic then what I am doing and had some typos. Let's try this again:

ghm = require("github-flavored-markdown");

exports.about = function(req, res) {
  Content.findOne({}, function(err, content) {
    content.body = ghm.parse(content.body);
    res.render('about/index', {
      content: content,
    });
  });
};

Then in about/index.jade

div !{content.body}


On Sun, Mar 4, 2012 at 5:50 AM, Brandon Martin<bma...@zyphmartin.com> wrote:
Sorry hit send by accident. Then in the view just did

div !{mission.body}


On Sun, Mar 4, 2012 at 5:48 AM, Brandon Martin<bma...@zyphmartin.com> wrote:
I had a similar issue before. I used github-flavored-markdown and parsed the markdown before handing off to the view. ie:

ghm = require("github-flavored-markdown");

exports.mission = function(req, res) {
  Content.findOne({}, function(err, content) {
    content.body = ghm.parse(content.body);
    res.render('about/index', {
      content: content,
    });
  });
};

Then in index.jade

 
On Sun, Mar 4, 2012 at 5:31 AM, Alfred Nerstu<alfred...@gmail.com> wrote:
Were just trying the same thing.

What are your suggested approach to this?

I've got the markdown-js package

Thanks!

On Sunday, February 5, 2012 5:11:38 PM UTC+1, vision media [ Tj Holowaychuk ] wrote:
filters are compile-time, they can't have access to vars since they're only compiled once

On Sun, Feb 5, 2012 at 7:56 AM, Geert Pasteels wrote:
How can I pass a variable to the markdown filter?

I tried

:markdown
  #{description}

:markdown=description

But none seem to be working.



댓글 없음:

댓글 쓰기