| Ratings |  | Unique User Downloads |  | Download Rankings | 
|     73% |  | Total: 186 |  | All time:  8,646 This week: 68  | 
|  | 
| Description |  | Author | 
| This class can generate HTML for page views from variable values.
 It takes the name of a HTML template file that will be used to define the core of a page that will be the current script output.
 
 The class can replace some given variable values in the template and will use the result to replace a main layout HTML template file to generate the final output.
 |  | 
|  |  | Innovation award 
  Nominee: 1x
 | 
 
 | 
Example
| 
<?php
 include_once 'View.php';
 
 // Create a new View. By default, it will search for main.html layout
 // Crear una nueva Vista. Por default, buscará el layout main.html
 $view = new View();
 
 // Set index.html as file to get contents (only name)
 // Elegir a index.html como el archivo para el contenido (solo el nombre)
 $view->setView('index');
 
 // Add external source files to <head> of Layout
 // Agregar archivos externos al <head> del Layout
 $view->addHeader('css/styles.css', 'css');
 $view->addHeader('js/functions.js');
 
 // Add data to {h} & {w} variables from index.html
 // Agregar datos a las variables {h} y {w} de index.html
 $view->add([
 'h' => 'Hello',
 'w' => 'World!'
 ]);
 
 // Print view
 // Imprimir vista
 $view->render();
 
 | 
Details
View
Generate Views from main Layout and HTML files with PHP
simple as:
$view = new View();
// Get contact.html and load into visitor_layout.html
$view->setView('contact', 'visitor_layout');
// Add <script> tag to <head> section
$view->addHeader('js/jquery.min.js');
// Add 'title' variable to <body> section
$view->add(['title' => 'Hello World!']);
// Print on screen
$view->render();
visitor_layout.html example:
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Example</title>
        
        {headers}
        
    </head>
    <body>
    
        {content}
    
    </body>
</html>
contact.html example:
<h1>{title}</h1>
- 
TODO:
- Set Arrays on variable views.
_Cause we can only set strings for now._
|  | Applications that use this package |  | 
No pages of applications that use this class were specified.
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.