All pastes #587048 Raw Edit

Unnamed

public text v1 · immutable
#587048 ·published 2007-06-24 06:59 UTC
rendered paste body

## Imbedding
<block name="ImbTest" >
  <a>(inner)</a>
</block>
<block name="ImbTest2" >
  <block name="ImbTest">
    GOD
  </block>
  (block ImbTest "inner")
</block>
#EXPAND
function tplImbTest( $inner ) {
  echo '<a>',$inner.'</a>';
}
function tplImbTest2( ) {
  echo tplImbTest( 'GOD' ), tplImbTest( 'inner' ); 
}

##variable arguments and arrays
<block name="ArgTest" with="arg1,arr1">
  (.arg1)<br />
  (.arr1.val1)<br />
</block>
#EXPAND
function tplArgTest( $arg1, $arr1 ) {
  echo $arg1, '<br />', $arg1['val1'], '<br />';
}

##session, request, get, post
<block name="GlobTest">
  (s.foo)<br />
  (r.foo)<br />
  (g.foo)<br />
  (p.foo)<br />
</block>
function tplGlobTest() {
  echo $_SESSION['foo'], '<br />',
       $_REQUEST['foo'], '<br />',
       $_GET['foo'], <br />,
       $_POST['foo'], <br />;
}

#iteration
<block name="IterTest" with="arr">
  (every .arr as .o)
  <a>(.o)</a>
  (end)
</block>
#EXPAND
function tplIterTest($arr) {
  foreach( $arr as $o ) {
    echo '<a>', $o, '</a>';
  }
}

##conditional
<block name="CondTest" with="o" >
  (cond (.o > 0) && (have s.z)
  foo
  (end)
</block>
# EXPAND
function tplCondTest() {
  if( ($o > 0) && isset($_SESSION['z']) ) {
    echo 'foo';
  }
}