¡Esta es una revisión vieja del documento!
What Are They? Views usually contain the majority of the HTML your pages display. By putting your HTML in views you keep it separate from the PHP and makes your HTML code a lot easier to read and manage.
Basic Usage Using views is really easy, as is everything else in Salem. To load a view you use the built in view function.
maincontroler.php
<?php namespace Controller; use Salem\View; class MainController { public function index() { View::render('hello'); } } ?>
Using the above function would load a view located at application/views/hello.php.
Passing Data To Views You can pass some data to your views like so:
maincontroler.php
<?php namespace Controller; use Salem\View; class MainController { public function index() { View::render('hello', array( 'title'=>'Amazing!', 'content'=>'That's cool !' ) ); } } ?>
hello.php
<?php use Salem\View; ?> <!DOCTYPE html> <html> <head><title> <? echo $title; ?> </title></head> <body> <b><? echo $title; ?></b> </body> </html>