我正试图在伏特中迭代一个模型集合:
{% if model.elements|length > 0 %}
{% for element in model.getElements() %}
{% include "partials/panels/edit-" ~ element.getType() ~ ".volt" %}
{% endfor %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)
类型可以是文本或图像.如果我使用上面的代码,我得到错误:
View '/path/to/phalcon/apps/frontend/views/partials/panels/edit-image.volt' was not found in the views directory
我确定该文件存在,因为如果我更改包含,它将起作用:
{% include "partials/panels/edit-image.volt" %}
Run Code Online (Sandbox Code Playgroud)
它也将失败:
{% include "partials/pandels/edit-" ~ "image.volt %}
Run Code Online (Sandbox Code Playgroud)
第一个版本产生错误的原因是什么?(我知道我可以使用ifs ..但是稍后会列出很多元素类型.)