diff --git a/Views.md b/Views.md new file mode 100644 index 0000000..25a2620 --- /dev/null +++ b/Views.md @@ -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, ''! + +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'); \ No newline at end of file