Szablon główny:
Kod
{# app/Resources/views/base.html.twig #}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="{{ asset('/css/main.css') }}" type="text/css" media="screen" />
<title>{% block title %}Test Application{% endblock %}</title>
</head>
<body>
<div id="sidebar">
{% block sidebar %}
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog">Blog</a></li>
</ul>
{% endblock %}
</div>
<div id="content">
{% block content %}
Content
{% endblock %}
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="{{ asset('/css/main.css') }}" type="text/css" media="screen" />
<title>{% block title %}Test Application{% endblock %}</title>
</head>
<body>
<div id="sidebar">
{% block sidebar %}
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog">Blog</a></li>
</ul>
{% endblock %}
</div>
<div id="content">
{% block content %}
Content
{% endblock %}
</div>
</body>
</html>
W paczce:
Kod
{# src/tpsa/pagesBundle/Resources/views/Default/index.html.twig #}
{% extends '::base.html.twig' %}
{% block content %}
{{ parent() }}
Ala<hr>
<img src="{{ asset('/images/ale.jpg') }}">
{% endblock %}
{# ... #}
{% extends '::base.html.twig' %}
{% block content %}
{{ parent() }}
Ala<hr>
<img src="{{ asset('/images/ale.jpg') }}">
{% endblock %}
{# ... #}
Co robię nie tak? Czytam już 5 razy o tworzeniu pierwszej strony w symfony2 i szablonach twig.
P.S.
{# #} to znaczą komentarze tak?