PHP code example of hokoo / templater

1. Go to this page and download the library: Download hokoo/templater 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/ */

    

hokoo / templater example snippets


use iTRON\Templater\Templater;
$t = new Templater();

/**
 * HTML Template
 * @var string 
 */
$template;


return $t->render( $template, [
    'foo', 
    'bar',
    'Where is the title?',
    'anything'
] );

return $t->render( $template, [
    'foo',
    'bar',
    [
        [ 'tag' => 'repeater_tag_name', 'data' => [ 'Is this a title?', 'anything' ] ],
        [ 'tag' => 'repeater_tag_name', 'data' => [ 'There is no title', 'anythingelse' ] ],
    ]
] );

$repeated_forms_a = [ 
    [ 'tag' => 'form', 'data' => [ 'form_1', $someform1 ] ], 
    [ 'tag' => 'form', 'data' => [ 'form_2', $someform2 ] ], 
];
$repeated_forms_b = [ 
    [ 'tag' => 'form', 'data' => [ 'form_3', $someform3 ] ], 
    [ 'tag' => 'form', 'data' => [ 'form_4', $someform4 ] ], 
];

return $t->render( $template, [
    'foo',
    'bar',
    [
        [ 'tag' => 'repeater_tag_name', 'data' => [ 'Is this a title?',  $repeated_forms_a ] ],
        [ 'tag' => 'repeater_tag_name', 'data' => [ 'There is no title', $repeated_forms_b ] ],
    ]
] );