问题描述
在Zend Framework中,可以为headMeta(),headLink()等设置缩进:
In Zend Framework, it is possible to set indentation for headMeta(), headLink(), etc:
<?= $this->headLink()->setIndent("\t\t") ?>
我喜欢这个.我喜欢整洁的东西.因此,现在我想在 layout.phtml 文件中缩进整个视图,从而使视图脚本中的每一行都缩进X标签.
I like this. I like things tidy. So, now I would want to indent my entire view as well in the layout.phtml file, causing every new line in the view script to be indented with X tabs.
<?= $this->layout()->setIndent("\t\t")->content ?>
这不起作用.在Zend Framework中有什么方法可以执行此操作而不必用ob_start截取输出吗?
This does not work. Is there any way to do this within Zend Framework without having to intercept the output with ob_start?
推荐答案
Zend_Layout没有setIndent()
,请在此处检查: http://framework.zend.com/apidoc/1.11/_Layout.html#Zend_Layout 您必须自己在模板中处理缩进.
Zend_Layout has no setIndent()
, check here: http://framework.zend.com/apidoc/1.11/_Layout.html#Zend_Layout You have to take care of the indentation by yourself in your template.
一个通用的解决方案是使用 整洁使用Zend Framework .届时使用的选项将是
A generic solution would be to use Tidy with Zend Framework. The options to use then would be
indent => true
indent-spaces => 4
这篇关于在Zend Framework中的视图上设置缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!