<nephtali>

A simple, flexible, fast, and security-focused PHP framework
Nephtali documentation

Hello World! (redux)

Perhaps the first Hello World! example lacks a certain je ne sais quoi. We can easily add some flair.

Code

Markup in hello-redux.php

<div id="content">
<!--pipe:hello-->
<!--view:default-->
<p>{greeting}  It's {weekday}!</p>
<p>A special hi to my co-workers:</p>
<ul>
   <!--data-->
   <li>{fname} {lname}</li>
   <!--data-->
</ul>
<!--view:default-->
<!--view:error-->
<p>Pardon our rudeness.</p>
<!--view:error-->
<!--pipe:hello-->
</div>

PHP in nsite/hello-redux.php

n\output\register(
   $name = 'greeting',
   $val = 'Hello World!'
);
n\output\register(
   $name = 'weekday',
   $val = strftime("%A")
);
n\pipe\register(
   $name = 'hello',
   $function = function($markup)
   {
      return n\view\render($view = 'default', $markup, $rows = array(
         array('fname' => 'Julia', 'lname' => 'Richardson'),
         array('fname' => 'Brianna', 'lname' => 'Richardson')
      ));
   }
);

Output

<div id="content">
<p>Hello World!  It's Monday!</p>
<p>A special hi to my co-workers:</p>
<ul>
   <li>Julia Richardson</li>
   <li>Brianna Richardson</li>
</ul>
</div>
blog comments powered by Disqus