technosophos/querypath — pull request #74 by TomorrowToday (2012-02-17 16:47:54+00:00)
Title: tplArrayR issue 73 fix

I completely rewrote tplArrayR again... :-)

All previous functionality is there, but attributes are handled a bit different.

old method of adding an attribute:

```$data['.classname@href'] = "http://www.github.com"```

new method for adding an attribute:

```$data['.classname'] = array('@href' => "http://www.github.com");```

it's wrapped in an array so you can set multiple attributes and values. When setting the value of the element you are currently in, the tplArrayR needs a string key to signal that it should be appended to the current selection. ':self' serves that purpose.

Full selectors now available as well

```
$data['.post'] = array(
'img' => array( '@src' => $src ), //set the src attribute of any img elements inside .post to $src
'@id' => 'post' . $id, //give the post a unique id
'h3' => $title, //append $title to any h3 elements in this post
':self' => $desc, //append $desc to this post
'.author' => $author //append $author to any elements of class author in this post
);
```

Performance improved slightly because I was able to remove branch() in many places.