PHP code example of dwoo / dwoo

1. Go to this page and download the library: Download dwoo/dwoo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dwoo / dwoo example snippets



// Include Composer autoloader
eusable
$dwoo = new Dwoo\Core();

// Load a template file (name it as you please), this is reusable
// if you want to render multiple times the same template with different data
$tpl = new Dwoo\Template\File('path/to/index.tpl');

// Create a data set, if you don't like this you can directly input an
// associative array in $dwoo->get()
$data = new Dwoo\Data();
// Fill it with some data
$data->assign('foo', 'BAR');
$data->assign('bar', 'BAZ');

// Outputs the result ...
echo $dwoo->get($tpl, $data);
// ... or get it to use it somewhere else
$dwoo->get($tpl, $data);


// To loop over multiple articles of a blog for instance, if you have a
// template file representing an article, you could do the following :

have been retrieved from the DB
foreach($articles as $article) {
    // Either associate variables one by one
    $data = new Dwoo\Data();
    $data->assign('title', $article['title']);
    $data->assign('content', $article['content']);
    $pageContent .= $dwoo->get($tpl, $data);

    // Or use the article directly (which is a lot easier in this case)
    $pageContent .= $dwoo->get($tpl, $article);
}