You could create a custom collection type and name the editor to match that.
Assuming you created custom collection called Tags
you could change your model to:
class MyModel
{
Tags Tags { get; protected set;}
}
Then you would name your editor and display templates Tags.ascx
.
Which would make your view code work like you wanted:
<%= Html.EditorFor(t => t.Tags) %>
For the custom collection you basically just create a wrapper around an implementation of a generic collection and expose it's methods and properties:
public class Tags : IList<Tag>
{
//Use a private List<Tag> to do all the
//heavy lifting.
private List<Tag> _tags;
public Tags()
{
_tags = new List<Tag>();
}
public Tags(IEnumerable<Tag> tags)
{
_tags = new List<Tag>(tags);
}
#region Implementation of IEnumerable
public IEnumerator<Tag> GetEnumerator()
{
return _tags.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _tags.GetEnumerator();
}
#endregion
#region Implementation of ICollection<Tag>
public void Add(Tag tag)
{
_tags.Add(tag);
}
public void Clear()
{
_tags.Clear();
}
public bool Contains(Tag tag)
{
return _tags.Contains(tag);
}
public void CopyTo(Tag[] array, int arrayIndex)
{
_tags.CopyTo(array, arrayIndex);
}
public bool Remove(Tag tag)
{
return _tags.Remove(tag);
}
public int Count
{
get { return _tags.Count; }
}
public bool IsReadOnly
{
get { return false; }
}
#endregion
#region Implementation of IList<Tag>
public int IndexOf(Tag tag)
{
return _tags.IndexOf(tag);
}
public void Insert(int index, Tag tag)
{
_tags.Insert(index, tag);
}
public void RemoveAt(int index)
{
_tags.RemoveAt(index);
}
public Tag this[int index]
{
get { return _tags[index]; }
set { _tags[index] = value; }
}
#endregion
}