目前还不能内置。
但是已经用这个函数实现了缩小选项。
function minifyHTML($content)
{
$start = strpos( $content, '[#strip#]');
if ($start > 0) {
$end = strpos($content, '[#endstrip#]');
$part = substr($content,$start, $end - $start + 12);
$content = str_replace($part,str_replace(array("\r", "\n", "\t" ,
'[#strip#]', '[#endstrip#]'), '' , $part) , $content);
if(strpos( $content, '[#strip#]') > 0)
$content = stripHTML($content);
}
return $content;
}
然后在你的 volt 文件中像这样使用它。但请确保在您的 volt 文件中使用制表符作为缩进而不是空格。 [#strip#] 标签也不允许嵌套。
<!DOCTYPE html>
<html lang="nl">
<head>[#strip#]
<meta charset="utf-8">
{% block head %}
{{ assets.outputCss() }}
{% endblock %}
<title>{% block title %}{% endblock %}</title>
[#endstrip#]</head>
<body>
{% block content %}
{% endblock %}
{% block script %}
[#strip#]{{ assets.outputJs() }}[#endstrip#]
{% endif %}
{% endblock %}
</body>
</html>
最后在你的 handle()->getContent() 上使用它。
$application = new \Phalcon\Mvc\Application($di);
echo minifyHTML( $application->handle()->getContent());