Skip to content

Instantly share code, notes, and snippets.

@jmlweb
Created July 16, 2011 18:59
Show Gist options
  • Save jmlweb/1086640 to your computer and use it in GitHub Desktop.
Save jmlweb/1086640 to your computer and use it in GitHub Desktop.
Selectors plugin for Turbine CSS
<?php
/**
* CSS3 Selectors Plugin for Turbine
* José Manuel Lucas
*
* http://github.com/jmlweb/turbine_transitions
*
*/
/**
* Allow CSS3 Selectors line :nth-child, etc
*
* How to use: :nth-child|3n|, etc
*
* @param mixed &$parsed
* @return void
*/
function selectors(&$parsed){
global $cssp, $browser;
foreach($parsed as $block => $css){
$selectors = array_keys($parsed[$block]);
$values = array_values($parsed[$block]);
foreach($selectors as $k => &$v){
if(preg_match('/:nth-child/', $v)){
$v = preg_replace('/\|([0-9]+n)\|/', '($1)', $v);
}
}
$parsed[$block] = array_combine($selectors, $values);
}
}
/**
* Register the plugin
*/
$cssp->register_plugin('selectors', 'selectors', 'before_glue', 0);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment