PHP code example of pytocryto / pytotpl

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

    

pytocryto / pytotpl example snippets


$tpl = new \PytoTPL\PytoTPL();
$tpl->setConfig([
    'tpl_folder'      => __DIR__ . '/dir/to/templates/',
    'cache_folder'    => __DIR__ . '/dir/to/cache/',
    'tpl_file_format' => '.tpl',
    'compress'        => false, // compression only available in a valid <HTML> document
    'event_emitter'   => true, // set to false for better performance
]);

{section.view: mySection}
html
{$variable}

{$array.key1.key2.key3}

{echo $variable}

{print $variable}

{$variable|substr:0,-1}
html
{!! $variable !!}
html
{foreach: $myArray as $item}
..
{/foreach}

{for: $i = 0; $i < 99; $i++}
..
{/for}

{while: $i < 9}
..
{/while}
html
{if: isset($data)}
    Yes
{else}
    Nope
{/if}

{-- or --}

{if: empty($data)}
    ...
{/if}
html
{isset: $data}
    Yes
{else}
    Nope
{/isset}

{-- or --}

{empty: $data}
    ...
{/empty}
html
{continue}
{break}
html
{if: $userid == 1}
    {continue}
{/if}