mennovanslooten/mockJSON — pull request #8 by elijahmanor (2013-03-11 20:42:57+00:00)
Title: Support named references for use in other templated properties

Over the past couple of years I have wanted the ability to reference the output of one templated item inside another property. This hasn't been available from what I've seen so I've make some minor tweaks to support this feature.

## Basic Usage

If you want to name the output of a templated property then append the name with `|$someKey`. To use the value you would just reference the `$someKey` inside the value of your templated item. See the following for an example

```javascript
$.mockJSON.generateFromTemplate({
"name|$1": "@LOREM",
"path": "My @LOREM",
"created": "@DATE_YYYY@DATE_MM@DATE_DD",
"created by|$2": "@LETTER_UPPER.@LAST_NAME",
"title": "My $1 by $2",
});
```

The output of the above snippet would show something like the following

![output](http://cl.ly/image/0t3q3p3m153y/Screen%20Shot%202013-03-11%20at%203.34.25%20PM.png)

## Limitations

* You can't combine the naming feature (`|$someKey`) and the auto-increment feature (`|+1`)
* You can only use a named reference for items already generated. You will notice I don't reference `$1` or '$2` until after I have named them

This feature could be a lot better, but in the meantime it does provide value.