markdown_to_html
2.12
的markdown_to_html
过滤器在树枝2.12中添加。
的markdown_to_html
将一块减价转换为HTML过滤:
1 2 3 4 5 6
{%应用markdown_to_html %}标题= = = = = =你好!{%endapply%}
注意,您可以缩进减记的内容作为主要的空格将被删除之前一直转换:
1 2 3 4 5 6
{%应用markdown_to_html %}标题= = = = = =你好!{%endapply%}
您还可以使用过滤器包括文件或一个变量:
1 2 3
{{包括(“some_template.markdown.twig”)| markdown_to_html}}{{changelog | markdown_to_html}}
请注意
的markdown_to_html
过滤器的一部分MarkdownExtension
这不是默认安装。安装:
1
美元需要树枝/ markdown-extra作曲家
然后,在Symfoob娱乐下载ny项目,安装树枝/ extra-bundle
:
1
美元需要树枝/ extra-bundle作曲家
否则,在树枝上添加扩展明确环境:
1 2 3 4
使用嫩枝\额外的\减价\MarkdownExtension;美元嫩枝=新\树枝\环境(…);美元嫩枝- >addExtension (新MarkdownExtension ());
如果你不使用Symfony,你还必须注册扩ob娱乐下载展运行时:
1 2 3 4 5 6 7 8 9 10 11
使用嫩枝\额外的\减价\DefaultMarkdown;使用嫩枝\额外的\减价\MarkdownRuntime;使用嫩枝\RuntimeLoader\RuntimeLoaderInterface;美元嫩枝- >addRuntimeLoader (新类实现了RuntimeLoaderInterface{公共函数负载(美元类){如果(MarkdownRuntime::类= = =美元类){返回新MarkdownRuntime (新DefaultMarkdown ());}}});
之后你需要安装一个减价库的选择。有些人提到的require-dev
部分的树枝/ markdown-extra
包中。