Closed marcghorayeb closed 12 years ago
I've used it without any problem.
<!-- default.html.twig -->
{% extends "generic.html.twig" %}
{% block body %}
{{ this.content }}
{% endblock %}
<!-- generic.html.twig -->
<!DOCTYPE>
<html>
<head>
<title>{{ this.title }}</title>
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
Tested and confirmed working.
Yeah i got it to work, sorry for not closing the issue. However I was wondering if there was a way of defining the layout from within the view (which is the philosophy behind Twig i reckon) and that does not seem to work. One would need to change the view process I think, I might dive into it later this week and propose something :)
You mean changing what Lithium layout is used in the latter Lithium view? If so you can handle that in the controller at least.
Yes I can change it in the controller :) But you can clearly separate tasks by using the extends feature in place and defining it in the view template directly. This way you can have webdesigners just focus on html without the need of specifying the layout in the controller which is more or less the real use behind the "extends" tag I think. This make things like defining the page title inside the view (which will override a title block for example) and not inside the controller.
@marcghorayeb actually title
is a pretty bad example: $this->title("my title")
. One suggestion could be to remove the layout step from the rendering process while using twig and relying only on extends
.
@greut well ok, but you get my point behind the extends :) title is the basic example used in a lot of example for block overrides but yeah it's the most stupid too ;)
i tried disabling the layout process but strangely twig doesn't like to extend a layout that's not inside the first template's directory, even by changing the directory path used to initialise it.
The library crashes when I try to extend a view using the {% extends .... %} tag. I don't see any error code or anything :(