Twig 如何禁用删除空格 [英] Twig how to disable removing white spaces

查看:27
本文介绍了Twig 如何禁用删除空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 symfony 项目,用 twig 作为模板引擎.我使用 raw 过滤器在语法高亮后显示 HTML 内容(通过使用 highlight.php,不幸的是我在制作 AMP 页面时无法使用 js 版本).Twig 删除了所有使代码无用的空格.代码在 pre 标签中,生成的 HTML 代码中也缺少空格.

I have a symfony project with twig as a template engine. I use raw filter to display HTML content after syntax highlight (by using highlight.php, unfortunately I'm not able to use js version as I make an AMP page). Twig removed all white spaces which makes the code useless. The code is in pre tag also spaces are missing in generated HTML code.

无论如何要禁用删除树枝中的空格?

Is there anyway to disable removing whitespaces in twig?

我知道如果我切换到 php 模板,它会被修复.

I know it would be fixed if I switch to php templates.

推荐答案

我发现了这个问题.在某些父模板中有 {% spaceless %} 正在删除空格!

I found the issue. In some parent template there was {% spaceless %} which was removing white spaces!

这篇关于Twig 如何禁用删除空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆