Created
July 16, 2011 18:59
-
-
Save jmlweb/1086640 to your computer and use it in GitHub Desktop.
Selectors plugin for Turbine CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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