[wp-hackers] Zen-Coding for WordPress?

Philip Walton philip at philipwalton.com
Wed Mar 30 22:16:57 UTC 2011


Paul, yes, It is a module for a text editor, but I think it would also 
be useful programmatically. To use the example from the link you posted:

div#page>div.logo+ul#navigation>li*5>a

In a text editor I would type this, click whatever shortcut key, and 
then the editor would expand the code into the full HTML markup saving 
me lots of time.

In addition to this, I could also see situations where you wouldn't know 
what your markup is going to look like until runtime (perhaps it is 
generated based on plugin settings), and being able to programmatically 
create that string selector -- and then have a set of methods that could 
expand it -- would be quite valuable.

Imagine if the above code instead looked like this:

$selector = 'div#' . $sidebar_id . '>div.' . $logo_class . '+ul#navigation>li*' . $link_count . '>a';

I know I'd use such code, and if there's nothing already out there 
specifically for WordPress -- that takes advantage of esc_attr() and 
esc_url() and such -- I'd be willing to make it myself.

On 3/30/11 2:55 PM, Paul wrote:
> On Mar 30, 2011, at 5:31 PM, Philip Walton wrote:
>
>> Is anyone aware of a plugin or theme framework that implements some version of zen-coding not within a text editor but actually as a set of php methods or functions?
>>
>> If not I'd be willing to start working on something, and I wanted to float the idea out there to gauge the general interest level and/or see if anyone wants to get involved.
>>
>> Basically, I'm wanting to be able to do something like this within WordPress themes and/or functions instead of writing a million hard-to-read echo statements.
>>
>> $zc = new Zen_Coder;
>> $zc->expand( "#sidebar>.wrapper>ul.widget>li.item$*3>a", array( $link1_data, $link2_data, $link3_data) );
>>
> Sort of confused. At first I thought this was a typo and you were referring to using the Zend Framework. But found Zen Coding http://code.google.com/p/zen-coding/
>
>  From what I can tell this is more a module for your coding environment like Coda, Textmate, Eclipse, Visual Studio. Not something that runs on a server and therefore directly integrated with WordPress to parse the PHP at the time the page is requested. Unless I'm missing something.
>
> P-
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list