开发者

Ruby/Slim: parse Markdown from a YAML file

开发者 https://www.devze.com 2023-04-08 02:07 出处:网络
Been struggling for a while with some YAML parsing inside a Slim template. my YAML file contain shortdesc: >

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

精彩评论

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