【发布时间】:2018-06-03 16:29:22
【问题描述】:
我使用了TwigBridge,因为我更喜欢使用 Twig 而不是刀片。问题是扩展基本模板返回错误。
加载 ../resources/views/main/index.twig 时出错:模板 “../layouts/base.index.twig”未定义(TwigBridge\Twig\Loader: 查看 [../layouts/base.index] 未找到。)在 “../resources/views/main/index.twig”
我尝试过像这样扩展模板,但它不起作用:
{% 扩展 '../layouts/base.index.twig' %}
{% 扩展 '../layouts/base.index' %}
这是资源/视图结构:
以下是视图文件的内容: base.index.twig
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{{ asset('css/bundle.css') }}">
</head>
<body>
{% block content %}
{% endblock %}
<script src="{{ asset('js/bundle.js') }}"></script>
</body>
</html>
这是 index.twig
{% extends '../layouts/base.index.twig' %}
{% block content %}
<div class="page-header text-center my-5"> <h1>Laravel Todo App</h1> </div>
<div class="float-right pb-3 pr-3">
<button class="btn btn-primary"> Add todo </button>
</div>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Todo</th>
<th scope="col">Description</th>
<th scope="col">Deadline</th>
<th scope="col">Status</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
{% endblock %}
【问题讨论】:
-
删除 . twig 在其 github.com/rcrowe/TwigBridge 用法中告诉 {% extends "parent" %} 它的工作原理是这样的
-
已经试过了,还是不行。
-
同样的错误?或不同的,因为在此它找不到您的文件
-
同样的错误,即使我删除了扩展中的 .twig 也找不到 twig 文件
-
发布您的文件代码