PHP code example of yakub / simple-templating

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

    

yakub / simple-templating example snippets



$output = \Yakub\SimpleTemplating\Replace::compile(
	'Hi {{userName}}, you selected this options {{fn.implode(', ', options)}}',
	[
		'userName' => 'Jakub'
		'options' => [
			'PHP', 'SQL'
		]
	]
);

echo $output; // Output: "Hi Jakub, you selected this options PHP, SQL"

\Yakub\SimpleTemplating\Replace::compile($template, $scope, $flags);

["name" => "Jakub Miškech"]

["strtotimeValue" => "yesterday"]

["numberA" => "1.4"]

[
	"map" => ["typePK" => "name"],
	"displayName" => "title",
	"values" => [1, 2, 3],
	"forExplode" => "hi,hello",
	"types" => [
		["name" => "php", "title" => "PHP: Hypertext Preprocessor",
		["name" => "pg", "title" => "PostgreSQL"]
	]
]

["done" => 9, "total" => 100, "float" => "5.4" ]

["success" => true, "ok" => "ok", "notOk" => "not ok" ]


$output = \Yakub\SimpleTemplating\Replace::compile(
	'{{types[1]}}',
	[
		"types" => [
			["name" => "php", "title" => "PHP: Hypertext Preprocessor",
			["name" => "pg", "title" => "PostgreSQL"]
		]
	]
);

echo $output; // Output: "" array isn't transformed to string
echo json_encode($output->onlyOneParamValue); // Output: "{"name":"pg","title":"PostgreSQL"}"