Sluz v0.9.4 documentation

Available documentation:

010_basic_if.php

PHP:
<?php

///////////////////////////////////////////////////////////////////////////////
// Conditional syntax is available in the form of if/else.                   //
//                                                                           //
// Note: When an if statement references a variable that is *not assigned it //
// will be treated as if it were false.                                      //
///////////////////////////////////////////////////////////////////////////////

include("../sluz.class.php");
$s = new sluz();

$s->assign("weekday", date("D"));
$s->assign("kittens", [2,3,4,5,6,7]);
$s->assign("verbose", true);

print $s->fetch("tpls/010_basic_if.stpl");
Template:
{if $weekday === "Wed"}
<h1>It is Wednesday</h1>
{else}
<h1>It is not Wednesday</h1>
{/if}

{if count($kittens) > 4}<p>You have a lot of kittens</p>{/if}

{if !$quiet}<div>Here is some detailed information</div>{/if}

{if $verbose && !$quiet}Since we are not quiet, here is even more information{/if}