PHP code example of zaitsev / mthamlphp

1. Go to this page and download the library: Download zaitsev/mthamlphp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zaitsev / mthamlphp example snippets


<i class="a b  echo( implode(' ',array('c',$e))) ;

<i id="id_ echo( implode('_',array($c,'2'))) ;

<i  foreach(array('a'=>'a','b'=>$c, 'e'=> true ? $c : $e) as $k=>$v) {echo " data-$k=\"$v\" ";} 

<input  echo ((true)? "selected" :"") ;

<i class="a b  echo( implode(' ',array('c','d'))) ;

new MtHamlPHP\Environment('php', array('

<i class="a b  echo( implode(' ',array('c',$e))) ;

echo sprintf('string_with_function_call',$tag_name,$attribte_name,$attribute_value) 

<i  echo render_array('i','class',array('a','b',['c','d'])) 

<div  echo MtHaml\Runtime::renderAttributes(array(array('id', 'div'), array('class', (array($position,$item2['type'], $item2['urgency'])))), 'html5', 'UTF-8', false); 

<input class="cls" type="text">
<input id="id" value="valu" type="submit">
<input id="id" class="cls" type="text">

:php <?
haml
 %input{:selected=>if(true), :checked=>if($bool_false), :attribute=>if(!$bool_false)}
html
<input class="a" value=" echo($name) ;
yaml
helpers:
  'i' :         #<i> tag only
    class       :  /* %1$s.%2$s */ echo render_array('%1$s','%2$s',%3$s) 
haml
:php
  function render_array($tag,$attr,$arr){
      $fl=array() ;
      array_walk_recursive(
        $arr
        , function($i,$k) use (&$fl)
            {
	            $fl[]=$i;
            }
      );
      echo $attr.'="'.implode(' ',$fl).'"';
   }
:haml
  helpers:
    i :
        class:  echo render_array('%1$s','%2$s',%3$s)