drvc63490 2016-02-26 12:20
浏览 24
已采纳

如何在Twig中包含语句?

According to this page documentatation, the following code should work fine:

<div class="paginator">
    <strong>pagina</strong>
    <!-- Loop here -->
    <a class="current "href="#">1</a>
    <!-- End loop -->
    <!-- This tag is only an example: --><a href="#">2</a>
    {% include 'pagination.html.twig' with { 
        currentFilters: { myFilter: filtervariables }, 
        currentPage: page, 
        paginationPath: "myroute", 
        lastPage: totalPages, 
        showAlwaysFirstAndLast: true 
    } only %}
</div>

However it returns:

Unable to find template "pagination.html.twig" in something.html.twig at line (number).

The page is in the same folder as the pagination.html.twig so I can't seem to understand what's happening. Is there anyone that can explain me what is happening?

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • doucan2102 2016-02-26 12:28
    关注

    First, it's better to use the include function and not the tag ({{ include('pagination.html.twig, {}) }}), because the tag is deprecated and it will be removed at some point (http://twig.sensiolabs.org/doc/functions/include.html)

    Then, you have to use the full qualified path name to the template. if your pagination.html.twig is in in the app/Resources/foo/bar folder, you have to write foo/bar/pagination.html.twig. If it's in the src/Bundle/FooBundle/Resources/views/bar folder, you have to write @Foo/bar/pagination.html.twig

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM