Created Views (markdown)

master
shoully 10 years ago
parent fbe54fc678
commit 5da13626e7

@ -0,0 +1,25 @@
Flight provides some basic templating functionality by default. To display a view template call the `render` method with the name of the template file and optional template data:
Flight::render('hello.php', array('name' => 'Bob'));
The template data you pass in is automatically injected into the template and can be reference like a local variable. Template files are simply PHP files. If the content of the `hello.php` template file is:
Hello, '<?php echo $name; ?>'!
The output would be:
Hello, Bob!
You can also manually set view variables by using the set method:
Flight::view()->set('name', 'Bob');
The variable `name` is now available across all your views. So you can simply do:
Flight::render('hello');
Note that when specifying the name of the template in the render method, you can leave out the .php extension.
By default Flight will look for a `views` directory for template files. You can set an alternate path for your templates by setting the following config:
Flight::set('flight.views.path', '/path/to/views');
Loading…
Cancel
Save