Permalink
Browse files

Now supporting o('element[attr1="val1",attr2="val2"].class1.class2')

  • Loading branch information...
1 parent cbc2f9d commit 3c775fc96c1e5ae6a3e3f5cdfe1bac840551b748 @Artazor Artazor committed May 27, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 oxygen.class.php
View
17 oxygen.class.php
@@ -17,13 +17,26 @@ public static function open($tag = 'div', $data = array()){
$data = $tag;
$tag = 'div';
}
+ preg_match_all('/(([A-Za-z_]+)="([^"]+)")/', $tag, $attrs);
+ preg_match_all('/\.([A-Za-z_0-9]+)/', $tag, $classes);
+ $classes = $classes[1];
+ preg_match('/^[A-Za-z:_0-9]+/', $tag, $tagm);
+ $tag = $tagm[0];
+ $attrs = $attrs[1];
$call = self::$stack[self::$sp-1];
$remote = $call->instance->go();
if($remote != '/')$remote = $remote.'/';
$data['remote'] = $remote;
- $data['component'] = $call->name;
+ $data['component'] = $call->name;
$call->stack[$call->sp++] = $tag;
- echo '<' . $tag . ' class="' . self::getCssClass() . '"';
+ echo '<' . $tag . ' class="' . self::getCssClass();
+ foreach($classes as $class) {
+ echo ' '. $class;
+ }
+ echo '"';
+ foreach ($attrs as $a) {
+ echo ' '.$a;
+ }
if(is_array($data)) {
foreach ($data as $key => $value) {
echo ' data-' . $key . '="' . htmlspecialchars(json_encode($value)) . '"';

0 comments on commit 3c775fc

Please sign in to comment.