Skip to content

Commit

Permalink
fixed Twig templates and added a global layout (which is probably clo…
Browse files Browse the repository at this point in the history
…ser to what you would do in a real application)
  • Loading branch information
fabpot committed Aug 19, 2010
1 parent 8ae1d91 commit 6fdc656
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
10 changes: 10 additions & 0 deletions hello/views/layout.php
@@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php $view->slots->output('title', 'Hello Application') ?></title>
</head>
<body>
<?php $view->slots->output('_content') ?>
</body>
</html>
10 changes: 10 additions & 0 deletions hello/views/layout.twig
@@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title %}Hello Application{% endblock %}</title>
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
4 changes: 3 additions & 1 deletion src/Application/HelloBundle/Resources/views/Hello/index.twig
@@ -1,3 +1,5 @@
{% extends "HelloBundle::layout" %}

Hello {{ $name }}!
{% block content %}
Hello {{ name }}!
{% endblock %}
14 changes: 5 additions & 9 deletions src/Application/HelloBundle/Resources/views/layout.php
@@ -1,9 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php $view->slots->output('_content') ?>
</body>
</html>
<?php $view->extend('::layout') ?>

<h1>Hello Application</h1>

<?php $view->slots->output('_content') ?>
16 changes: 7 additions & 9 deletions src/Application/HelloBundle/Resources/views/layout.twig
@@ -1,9 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
{% extends "::layout" %}

{% block body %}
<h1>Hello Application</h1>

{% block content %}{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion src/autoload.php
@@ -1,6 +1,6 @@
<?php

$vendorDir = __DIR__.'/vendor';
$vendorDir = __DIR__.'/../vendor';

require_once $vendorDir.'/symfony/src/Symfony/Framework/UniversalClassLoader.php';

Expand Down
9 changes: 9 additions & 0 deletions web/index.php
@@ -1,6 +1,15 @@
<?php

xhprof_enable();

require_once __DIR__.'/../hello/HelloKernel.php';

$kernel = new HelloKernel('prod', false);
$kernel->handle()->send();

$xhprof_data = xhprof_disable();
include_once "/Users/fabien/work/symfony/2_0/blog/web/xhprof-0.9.2/xhprof_lib/utils/xhprof_lib.php";
include_once "/Users/fabien/work/symfony/2_0/blog/web/xhprof-0.9.2/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "PR2", 1);
echo "http://<xhprof-ui-address>/index.php?run=$run_id&source=products\n";

0 comments on commit 6fdc656

Please sign in to comment.