简体   繁体   中英

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? 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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM