Add more extensive example for mode="paired"

We said we would do this in answering a prior issue. 
https://www.npmjs.org/package/dustmotes-provide

From: Aria Stewart [mailto:notifications@github.com]
Sent: Monday, September 08, 2014 2:18 PM
To: krakenjs/makara
Cc: Ragan, Richard
Subject: Re: [makara] Add more extensive example for mode="paired" (#48)


In README.md:

> + stateList[AK]=Alaska

> + stateList[AZ]=Arizona

> + stateList[AR]=Arkansas

> + ...

> + ```

> +

> +With this, you have a viable representation that supports using the state code for the value in the option tag and the state name as the displayed value. To get the content into the template, you need to use the @pre tag. @pre inlines the content which, by itself, would create a problem for turning the above into a select list. To pull off the solution, you need two things: the mode="paired" parameter on the @pre tag and to use the @provide custom helper (https://github.com/rragan/dust-motes/tree/master/src/helpers/data/provide)

> +

> +mode="paired" causes the @pre tag to output the map as a JSON array with paired $id/$elt values.

> +Writing {@pre type="content" key="stateList" mode="paired" /} results in

> +

> + [{"$id":"AL","$elt":"Alabama"},{"$id":"AK","$elt":"Alaska"},... ]

> +

> +Now we have this JSON inlined in our template. To make the data available to template code, we need to make it accessible to dust as if it was in the data model or passed as a parameter.

> +

> +@provide processes each dust named block (e.g. {:stateList} in our case) creating a parameter bearing the name of the block and holding a value formed by a JSON.parse of the body of the block. The result of this, in our example, is equivalent to putting a parameter named stateList with value of a JSON array holding all the state data into the context where dust can reference it. Note that you can only use the name within the main block of provide -- the template area right after @provide up to the first named block.

Where is @provide from?

—
Reply to this email directly or view it on GitHub<https://github.com/krakenjs/makara/pull/48/files#r17267691>.