PHP code example of artem_c / emmet

1. Go to this page and download the library: Download artem_c/emmet 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/ */

    

artem_c / emmet example snippets


  $emmet = new Emmet('tr>td{`value`}');
  
  foreach($data as $value){
      echo $emmet->create([ 'value' => $value ]);
  }

  foreach($data as $value){
      echo (new Emmet('tr>td{`value`}'))->create([ 'value' => $value ]);
  }

'a+span'  ==== '<a></a><span></span>'

'a>span' === '<a><span></span></a>'

`div+h1` === '<div></div><h1></h1>'

 echo (new Emmet('ul>li{`ul[$]`}*2'))->create(['ul' => [1,2,3]]) === '<ul><li>1</li><li>2</li></ul>'
 

echo (new Emmet(
    'table#myTable>tbody>tr.myTr*`tr_cnt`>td.title{`data[$][title]`}+td{`data[$][value]`}')
)->create(
    ['data' => $data,'tr_cnt' => count($data),]
);

Emmet::addFunctions(['funcName' => function() { return 'funcName';}])

Emmet::addFUnctions(['funcName' => function($arg) { return ' ' . $arg . ' '; }])

 Emmet::addFunctions(['func' => function($a, $b, $c) { return $a.$b.$c; }]);
 echo (new Emmet('p{%func(`a`, b, `c`)%}'))->create(['a' => 'aaa', 'c' => 'ccc']) === '<p>aaabccc</p>'
 

 Emmet::addFunctions(['infoHeader' => 'Information header'])
 echo (new Emmet('div>header{%infoHeader()%}+section{some info}'))-create() === '<div><header>Information header</header><section>some info</section></div>'

 

  integer count( mixed ) // the same as 'count()' in php

  strinf select($name, $selected, array $data, array $html_options = []) // creates Select HTML Element

Emmet::addFunctions(['htmlFunction' => function(){ return 'function html node';}])
echo (new Emmet('div>`htmlVar`+%htmlFunction()%'))->create(['htmlVar' => 'variable html node']) === '<div>variable html nodefunction html node</div>'


echo (new Emmet('div+`myP`>a+span'))->create(['myP' => '<p class="myP">{{value}}</p>']) === '<div></div><p class="myP"><a></a><span></span></p>'

Emmet::addFunction(['oneMoreP' => '<p class="one more p">{{value}}</p>']);

echo (new Emmet('div>%oneMoreP()%>`myP`>a+a'))->create(['myP' => '<p class="myP">{{value}}</p>']) === '<div><p class="one more p"><p class="myP"><a></a><a></a></p></p></div>'

Emmet::addFunction(['func' => function($first, $second, $value) { return $first.' '.$second.' '.$value; }]);

echo (new Emmet('div>%func(first, `second`)%>`second`+a'))->create(['second' => 'second']) === 
'<div>first second second<a></a></div>'