jdiamond/Nustache — Issue #22: Using Model & sharing templates
Author: storhaug3
Created: 2012-02-25 05:51:26+00:00
State: open

The current way to access model properties in templates is {{Model.SomeProperty}}, which seems appropriate because it follows the convention that Razor templates use. However, this requires mustache templates to either have the Model. prefix on every property, or a {{#Model}} block around the template. Now this isn't too bad, except for when I need to share my templates between server / client, in which case I must have a root "Model : ... " property in my JSON data as well.

To avoid this ugliness, I suppose that I could just use ViewBag properties, but I like the idea of being able to just send one class as the model (it works well with the way I use automapper). Plus, using the ViewBag/ViewData just _feels_ wrong :).

It would be a quick change to change (back) the way Model properties are accessed in templates, and I think I'll do so for myself, but I just wanted you to to be aware of this (IMO, valid) reason to break the convention that Razor sets.