Zen Coding: Generating HTML from selectors
Author: Dion Almaer
23
Nov
Normally we use CSS selectors to find and tear apart HTML. Sergey Chikuyonok's jujitsu move is to do the opposite. With Zen Coding you take a CSS selector like this:
HTML:
html:xt>div#header>div#logo+ul#nav>li.item-$*5>a
and it generates an HTML structure like this:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang ="en" >
<meta http-equiv ="Content-Type" content ="text/html;charset=UTF-8" />
</head>
<li class ="item-1" > <a href ="" > </a> </li>
<li class ="item-2" > <a href ="" > </a> </li>
<li class ="item-3" > <a href ="" > </a> </li>
<li class ="item-4" > <a href ="" > </a> </li>
<li class ="item-5" > <a href ="" > </a> </li>
</ul>
</div>
</body>
</html>
You can check out a demo or try out support in various editors (Aptana to TextMate ).
Now I want to create a Bespin plugin to do this too!
Related News :