2

I have code for a T4 template that has two for each loops, and one is inside the other.

I am having an issue escaping the inner for each and pass data from the parent for each.

The image below demonstrates the variable data I am trying to pass from the parent for each to the child for each.

I have tried:

foreach (var prop in GetPropertiesNameOfClass(#><#=item #><#))
foreach (var prop in GetPropertiesNameOfClass(#>item<#))

when I transform the template it generates an error:

  • CS1525 error Invalid expression term ')'

  • CS1002 error ; expected

enter image description here

CodeMilian
  • 1,262
  • 2
  • 17
  • 41
  • It was as simple as that and I thought I tried that but clearly I did not. I wish I could mark your comment as the answer because it is. – CodeMilian Oct 06 '15 at 08:34

1 Answers1

3

You are already inside of <# #> context, so you does not need any additional escaping to refer to item variable in your code:

foreach (var prop in GetPropertiesNameOfClass(item))
user4003407
  • 21,204
  • 4
  • 50
  • 60