开发者

Ruby/Slim: parse Markdown from a YAML file

Been struggling for a while with some YAML parsing inside a Slim template.

my YAML file contain

shortdesc: >
 markdown:
  if you want to up the feelgood factor Cuban style, then this Monday night at The Buffalo    Bar is for you...

But when I output the shortdesc node in my template it's displayed as a string and not interpreted. ("markdown: if you....")

Is there a way to parse the YAML output string to interpret the markdown code开发者_如何学JAVA? If I try

p
  markdown:
    = shortdesc

the template doesn't understand the call to the variable containing the YAML node.

Is that even possible?


It depends on the Markdown Library that you are using.

In BlueCloth, it would be something like this:

= BlueCloth.new(shortdesc).to_html


Yes it's possible. Just need to use interpolation:

p
  markdown:
    #{shortdesc}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜