我正在尝试以伏特遍历模型集合:
{% if model.elements|length > 0 %}
{% for element in model.getElements() %}
{% include "partials/panels/edit-" ~ element.getType() ~ ".volt" %}
{% endfor %}
{% endif %}
类型可以是文本或图像。如果我使用上面的代码,我会得到错误:
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" %}
它也会失败:
{% include "partials/pandels/edit-" ~ "image.volt %}
第一个版本产生该错误的原因是什么?(我知道我可以只使用 ifs .. 但是稍后会有相当多的元素类型列表。)