jdiamond/Nustache — pull request #44 by lukemerrett (2012-11-27 10:08:42+00:00)
Title: Preserving undefined variables

Hi Jason,

We've been using Nustache for a while now for constructing email bodies (and frankly love it) however to ensure that our templates are being properly populated by data we wanted to create a series of integration tests checking the replacement.

The issue we were having was that Nustache removes any undefined variables if they do not have matching data. This is great for production; but in a development environment it would be useful to us to see the variables that are not being defined.

Please see the attached commits for the implementation of this; I've tried to ensure existing functionality remains untouched; the main changes are:

* New Options object with a PreserveUndefinedVariables property and a Defaults static method
* Render has a few new overloads (So as to preserve existing functionality) for passing in an Objects instance
* VariableReference.Render now checks this object on the context
* If PreserveUndefinedVariables is true it leaves the undefined variable in the resulting string
* Otherwise (and by default) the undefined variable is left in.

This is fairly specific to a series of integration tests we'd like to run; however I thought you may want a pull request all the same.

Bear in mind this is also my first (ever) pull request so any advice on making it better would be appreciated.

Cheers,
Luke