小编Cel*_*ain的帖子

如果路径连接,则不包括文件

我正试图在伏特中迭代一个模型集合:

{% 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 ..但是稍后会列出很多元素类型.)

phalcon volt

2
推荐指数
1
解决办法
1025
查看次数

标签 统计

phalcon ×1

volt ×1