Skip to content

Instantly share code, notes, and snippets.

@maximilianoraul
Last active August 29, 2015 14:11
Show Gist options
  • Save maximilianoraul/ff2316fe123ca8f54e87 to your computer and use it in GitHub Desktop.
Save maximilianoraul/ff2316fe123ca8f54e87 to your computer and use it in GitHub Desktop.
Flight Micro-Framework - Rendering Views with custom Layout
<h1><?php echo $text; ?></h1>
<?php
//####### Include Flight #######
require_once 'flight/Flight.php';
//######## Rendering Views with custom Layout #######
Flight::map('renderView', function($view = '', $data = array(),$title = 'Default Title'){
Flight::render($view, $data, 'body_content');
Flight::render('layout', array('title' => $title));
});
//####### Routes #########
Flight::route('GET /', function() {
//Use map function renderView() to render views
Flight::renderView('custom_view',array('text'=>'Hello World!'));
});
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php echo $body_content; ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment