Stringifiers

Php stringifier#

Install to your project:

npm i gutt-php-stringifier

What does contain finally php-file?

It is some boilerplate code with util functions and php5.6 closure function at return. It looks somwthing like that:

<?php...return function ($state = []) {	...	return $output;};

This function has one parameter: state. State is an php array with data.

It returnes a string with html markup.

This is an example of user case.

./template.gutt:

<switch>	<case test={$a > $b}>		a bigger than b	</case>	<case test={$a < $b}>		a smaller than b	</case>	<default>		a is equal b	</default></switch>

Compile it to php file with CLI (for example):

gutt ./template.gutt -s php-stringifier -o ./

Using:

<?php$template = include __DIR__ . "/template.gutt.php";
echo $template(['a' => 2, 'b' => 3]); // a smaller than b