Domanda

I'm playing with StringTemplate version 3.1.4.6002 as a view engine for an MVC project. I can't seem to access an object being passed to the template and have it render on a webpage. So basically, I have the the following in the controller (in C#):

var layer1 = new { count = "1", label = "Description" };
var layer2 = new { count = "2", label = "Transcription" };
ViewData["layers"] = new object[] {layer1,layer2};

On the view file test.st, I have:

$layers:{
   $it.count$
   $it.label$
}$

The template does not display anything on the webpage, but if I do this on the test.st:

$layers$

it displays the object as:

{ count=1, label=Description } { count=2, label=Transcription }

which looks like to me a string. So how do I access just the count and the label independently? I've googled a lot already and can't seem to find anything that would fix my problem.

By the way, I'm using Visual Studio V10 and .NET Framework Version4. On the project I have References to Antlr3.Runtime, Antlr3.Runtime.Debug and Antlr3.StringTemplate dlls. Also, I have no problems accessing simple string objects. I've used the tutorial project in here. I can supply more details if required.

È stato utile?

Soluzione

Are the count and label fields public or, if they are getters, are they public?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top