symfony2 - 如何从树枝中包含树枝
symfony2 - how to include a twig from a twig
学习 sympony2 我遇到了困难并尝试了很多解决方案但似乎没有任何效果,我不断得到
Unable to find template "ScoreBoardViewerBundle.Viewer.scoreboard_keeper.html.twig" in
ScoreBoardViewerBundle:Viewer:view.html.twig at line 15.
这是我剪下的树枝:
{% if score_keeper=='sk' %}
{% include 'ScoreBoardViewerBundle.Viewer.scoreboard_keeper.html.twig' with {'score_keeper' : score_keeper} %}
{% else %}
{% include 'ScoreBoardViewerBundle.Viewer.scoreboard.html.twig' %}
{% endif %}
最初我只有文件名,就像我在这个 twig 站点的示例中看到的那样:Twig site 但是产生了同样的错误。树枝文件位于同一目录中。
我做错了什么?此外,无论我尝试包含哪个文件,我都会遇到同样的问题。我确实有一些错别字,但应该改正了。
这是我使用的控制器,它能够正确打开两个视图,我只是注意到每个文件中的一些树枝是多余的,因此进行了更改
public function viewAction($score_keeper)
{
//returns scoreboard view for score keeper
// if($score_keeper=="sk"){
// return $this->render('ScoreBoardViewerBundle:Viewer:keeper.html.twig',array('score_keeper' => $score_keeper));
// }
//returns scorboard view for all others
return $this->render('ScoreBoardViewerBundle:Viewer:view.html.twig',array('score_keeper' => $score_keeper));
}
您的 {% include %}
语句中有错字。您应该使用 :
而不是 .
来分隔模板名称中的块。
试试这个:
{% if score_keeper=='sk' %}
{% include 'ScoreBoardViewerBundle:Viewer:scoreboard_keeper.html.twig' with {'score_keeper' : score_keeper} %}
{% else %}
{% include 'ScoreBoardViewerBundle:Viewer:scoreboard.html.twig' %}
{% endif %}
学习 sympony2 我遇到了困难并尝试了很多解决方案但似乎没有任何效果,我不断得到
Unable to find template "ScoreBoardViewerBundle.Viewer.scoreboard_keeper.html.twig" in ScoreBoardViewerBundle:Viewer:view.html.twig at line 15.
这是我剪下的树枝:
{% if score_keeper=='sk' %}
{% include 'ScoreBoardViewerBundle.Viewer.scoreboard_keeper.html.twig' with {'score_keeper' : score_keeper} %}
{% else %}
{% include 'ScoreBoardViewerBundle.Viewer.scoreboard.html.twig' %}
{% endif %}
最初我只有文件名,就像我在这个 twig 站点的示例中看到的那样:Twig site 但是产生了同样的错误。树枝文件位于同一目录中。
我做错了什么?此外,无论我尝试包含哪个文件,我都会遇到同样的问题。我确实有一些错别字,但应该改正了。
这是我使用的控制器,它能够正确打开两个视图,我只是注意到每个文件中的一些树枝是多余的,因此进行了更改
public function viewAction($score_keeper)
{
//returns scoreboard view for score keeper
// if($score_keeper=="sk"){
// return $this->render('ScoreBoardViewerBundle:Viewer:keeper.html.twig',array('score_keeper' => $score_keeper));
// }
//returns scorboard view for all others
return $this->render('ScoreBoardViewerBundle:Viewer:view.html.twig',array('score_keeper' => $score_keeper));
}
您的 {% include %}
语句中有错字。您应该使用 :
而不是 .
来分隔模板名称中的块。
试试这个:
{% if score_keeper=='sk' %}
{% include 'ScoreBoardViewerBundle:Viewer:scoreboard_keeper.html.twig' with {'score_keeper' : score_keeper} %}
{% else %}
{% include 'ScoreBoardViewerBundle:Viewer:scoreboard.html.twig' %}
{% endif %}