ariatemplates/hashspace — pull request #162 by divdavem (2014-05-03 11:13:16+00:00)
Title: Removes unnecessary global var access when cpt path is in local scope

Consider the following template:

```
# template myTpl using c:Ctrl
<#c.tpl />
# /template
```

Before this pull request, the compiler was generating the following code:

```js
var myTpl = require("hsp/rt").template({ctl:[Ctrl,"Ctrl"],ref:"c"}, function(n){
var _c;try {_c=c} catch(e) {};
return [n.cpt([_c,"c","tpl"],0,0,0)];
});
```

Note the unexpected access to the global `c` variable, which is stored in `_c` in a `try`...`catch` block.

As we know the `c` variable is in the scope in this case, this pull request changes the compiler to generate the following code instead:

```js
var myTpl = require("hsp/rt").template({ctl:[Ctrl,"Ctrl"],ref:"c"}, function(n){
return [n.cpt([null,"c","tpl"],0,0,0)];
});
```