Template, iterate with an item template

What is the syntax to render one or more items with a template. See this sample, but this is not working.

__Contacts = IEnumerable<IDictionary<string,object>>

<table>
{{ __Contacts | select:
  <tr style='border: 0px !important;border-bottom: 1px solid #ddd !important;'>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{it.Title}</td>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{it.JobTitle}</td>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'><a href='mailto:{it.Email}'>{it.Email}</a></td>	
		<td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{it.WorkPhone}</td>
  </tr>
}}
</table>

I also tried

{it['Title']}

or this with the same result, values from the dictionary are not rendered

{{ "
  <tr style='border: 0px !important;border-bottom: 1px solid #ddd !important;'>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{{it['Title']}}</td>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{{it.JobTitle}}</td>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'><a href='mailto:{{it.Email}}'>{{it.Email}}</a></td>	
		<td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{{it.WorkPhone}}</td>
  </tr>
" | forEach(__Contacts)
}}

The select: needs to be on a single line, otherwise you can use a partial.

Is it possible to define a partial within the same template? (Rendering without a http context, no physical files and single place to define the template text)

No you cannot define partials inside templates.

If it’s not a single line you can’t use short-hand syntax and will need to use the full notation, e.g:

<table>
{{ __Contacts | select("
  <tr style='border: 0px !important;border-bottom: 1px solid #ddd !important;'>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{{it.Title}}</td>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{{it.JobTitle}}</td>
    <td style='border: 0px !important;border-bottom:1px solid #ddd !important;'><a href='mailto:{{it.Email}}'>{{it.Email}}</a></td>	
		<td style='border: 0px !important;border-bottom:1px solid #ddd !important;'>{{it.WorkPhone}}</td>
  </tr>")
}}
</table>

Thanks. and what about accessing the values in the IEnumerable Dictionary?

__Contacts = IEnumerable<IDictionary<string,object>>

but

{it['Title']}

doesn’t return a value

I don’t know what your question is, but using select works as expected:

var __Contacts = new List<Dictionary<string,object>> {
    new Dictionary<string,object> {
        { "Title", "foo" },
    },
    new Dictionary<string,object> {
        { "Title", "bar" },
    },
};

var context = new TemplateContext { 
    Args = { 
        { "__Contacts", __Contacts }
    }
}.Init();

var output = context.EvaluateTemplate("{{ __Contacts | select('<td>{{ it.Title}}</td>') }}");

Which returns the expected:

<td>foo</td><td>bar</td>

Feel free to create a new example of Gistlyn if you mean something else.