为什么不解释Twig标签?

时间:2015-10-30 15:10:40

标签: php html css twig silex

我目前正在将标准设置为一个PHP项目,该项目是编码框架而没有前者(视图中的JS / SQL / PHP)。 所以我重构了一个很大的部分,我正在为视图设置框架和Silex Twig模板引擎。 我的问题是Twig标签没有被执行(它们被引用): Source code HTML

你看到了什么: Error Twig

这是我的Twig页面的代码,我认为必须有语法错误:

<!DOCTYPE html>
<html>
<div class="navbar-collapse collapse templatemo-sidebar"></br>
    <ul class="templatemo-sidebar-menu" id="listMenu">
        <li>
            <form class="navbar-form">
                <input type="text" class="form-control" id="templatemo_search_box" placeholder="Rechercher..." onkeyup="refreshSearch()">
                <span class="btn btn-default" onclick="searchItem(templatemo_search_box.value)"><i class="fa fa-search"></i></span>
            </form>
            <script src="../../web/js/script_inc_menubase.js"></script>
        </li>
        <!-- HOME -->
        <li class="active"><a href="../../views/app_main/aff_index.php"><i class="fa fa-home"></i>Home</a></li>

        {% include '../../src/ressources/DataModule/utilsdb.php' %}

        {% set login = mySession->getValue('login') %}
        {% include '../../src/include/inc_requeteMenuBase.php' %}

        <!-- HOME -->

        {% if SearchMenu('Administration', TabMenu) == true %}
            {% set TabURL = RecupURL(login, GetIndexM('Administration')) %}
            {% set TabPage = RecupNom(login, GetIndexM('Administration')) %}

            <!-- ADMINISTRATION -->
            <li class="sub">
                <a href="javascript:">
                    <i class="fa fa-users"></i> Administration <div class="pull-right"><span class="caret"></span></div>
                </a>
                <ul class="templatemo-submenu">
                    {% for i in i<count(TabURL) %}
                        <li><a  href='../../{{ TabURL[i] }}'> {{ TabPage[i] }}</a></li>
                    {% endfor %}

                </ul>
            </li>
        {% endif %}

        <!-- RAPPORTS -->
        {% if SearchMenu('Rapport', TabMenu) == true %}
            {% set TabURL = RecupURL(login, GetIndexM('Rapport') %}
            {% set TabPage = RecupNom(login, GetIndexM('Rapport') %}

            <li class="sub">
                <a href="javascript:">
                    <i class="fa fa-table"></i> Rapports <div class="pull-right"><span class="caret"></span></div>
                </a>
                <ul class="templatemo-submenu">
                    {% for i in i<count(TabURL) %}
                        <li><a  href='../../{{ TabURL[i] }}'> {{ TabPage[i] }}</a></li>
                    {% endfor %}
                </ul>
            </li>
        {% endif %}

        <!-- OUTILS -->
        {% if SearchMenu('Outils', TabMenu) == true %}
            {% set TabURL = RecupURL(login, GetIndexM('Outils') %}
            {% set TabPage = RecupNom(login, GetIndexM('Outils') %}

            <li class="sub">
                <a href="javascript:">
                    <i class="fa fa-flash"></i> Outils <div class="pull-right"><span class="caret"></span></div>
                </a>
                <ul class="templatemo-submenu">
                    {% for i in i<count(TabURL) %}
                        <li><a href='../../{{ TabURL[i] }}'> {{ TabPage[i] }}</a></li>
                    {% endfor %}
                </ul>
            </li>
        {% endif %}

        <!-- AUDITS (non utilisé pour le moment) -->
        {% if SearchMenu('Audits', TabMenu) == true %}
            {% set TabURL = RecupURL(login, GetIndexM('Audits') %}
            {% set TabPage = RecupNom(login, GetIndexM('Audits') %}
            <li class="sub">
                <a href="javascript:">
                    <i class="fa fa-tasks"></i> Audits <div class="pull-right"><span class="caret"></span></div>
                </a>
                <ul class="templatemo-submenu">
                    {% for i in i<count(TabURL) %}
                        <li><a href='../../{{ TabURL[i] }}'> {{ TabPage[i] }}</a></li>
                    {% endfor %}
                </ul>
            </li>
        {% endif %}

        <!-- GESTION DONNES -->
        {% if SearchMenu('Gestion Données', TabMenu) == true %}
            {% set TabURL = RecupURL(login, GetIndexM('Gestion Données') %}
            {% set TabPage = RecupNom(login, GetIndexM('Gestion Données') %}

            <li class="sub">
                <a href="javascript:">
                    <i class="fa fa-database"></i> Gestion Données <div class="pull-right"><span class="caret"></span></div>
                </a>
                <ul class="templatemo-submenu">
                    {% for i in i<count(TabURL) %}
                        <li><a href='../../{{ TabURL[i] }}'> {{ TabPage[i] }} </a></li>
                    {% endfor %}

                </ul>
            </li>
        {% endif %}
    </ul>
</div><!--/.navbar-collapse -->

</html>

1 个答案:

答案 0 :(得分:0)

请添加php代码,在这里定义Twig;你似乎为inlcudes设置了错误的路径;

检查模板文件夹的定义位置。并在模板中设置相对于模板路径的路径。

$loader = new \Twig_Loader_Filesystem(__DIR__.'/v2/Templates');