开发者

Apply multiple filters in haml (or wrap :markdown filter's content with a CDATA tag)

开发者 https://www.devze.com 2023-02-04 23:56 出处:网络
I\'m using HAML to generate a XML output. Inside one of the element I\'m using the :markdown filter to generate a small block of HTML code (for example, an unordered list of items).

I'm using HAML to generate a XML output. Inside one of the element I'm using the :markdown filter to generate a small block of HTML code (for example, an unordered list of items).

!!! XML
  %root
    %child
      :markdown
        * item 1
        * item 2
        * item 3 

Is it possible to wrap this generated HTML with a CDATA so that the XML file is valid?

<root>
  <child><![CDATA[
    <ul>
      <li>item 1</li>
      <li>item 2</li>
      &开发者_如何学JAVAlt;li>item 3</li>
    </ul>
  ]]></child>
</root>

Thanks!


From other source that currently it's not possible to chain filters together so there's no ready-made solution.

What I've done is create a custom filter that's similar to the build-in :markdown one and wrap the output with the CDATA tag. Works like a charm.

0

精彩评论

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

关注公众号