PHP code example of azettl / php-nano-template

1. Go to this page and download the library: Download azettl/php-nano-template 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/ */

    

azettl / php-nano-template example snippets


$nano = new com\azettl\nano\template();
$nano->setTemplate(
  "<p>
    {user.greeting()} {user.function(2)} {user.function('test')} {user.first_name} {user.last name}! 
    Your account is <strong>{user.account.status}</strong> 
    {user.nonexistingnode}
  </p>"
);
$nano->setData($aData);
$nano->setShowEmpty(true);

echo $nano->render(); 

$nano = new com\azettl\nano\template(
  "<p>
    {user.greeting()} {user.first_name} {user.last name}! 
    Your account is <strong>{user.account.status}</strong> 
    {user.nonexistingnode}
  </p>",
  [
    "user" => [
      "login" => "demo",
      "first_name" => "Anon",
      "last name" => "Ymous",
      "account" => [
        "status" => "active",
        "expires_at" => "2016-12-31"
      ],
      "greeting" => function(){
        return 'Hello';
      },
      "function" => function($param){
        return 'Test' . $param;
      }
    ]
  ]
);

echo $nano->render(); 

$nano = new com\azettl\nano\template();
$nano->setTemplateFile(
  "tests/template.html"
);
$nano->setData($aData);

echo $nano->render(); 
cmd
composer