could probably replace most of the logic in this function with _.template configured with '{}' as its delimiters.  Would be more robust for extension.