040_literal_blocks.php
open standalone ↗
PHP Source
<?php
///////////////////////////////////////////////////////////////////////////////
// You may need a literal '{' or '}' in your HTML. These characters are //
// common in both CSS and Javascript. To prevent Sluz from interpretting //
// them as code blocks use {literal}. //
// //
// Note: Brackets with whitespace on both sides do NOT require {literal} //
///////////////////////////////////////////////////////////////////////////////
include("../sluz.class.php");
$s = new sluz();
$s->assign("name", "Jason Doolis");
print $s->fetch("tpls/040_literal_blocks.stpl");
TPL Template
<script>
var name = "{$name}";
{literal}
function hello_world() {
alert("Hi there " + name);
}
{/literal}
</script>
<button onclick="hello_world();">Click me</button>
OUT Live output
iframe preview