Sorry for the late reply. Hopefully you got it working, but just in case (and for future visitors):
Yes, you could use the assign tag to do it. This works:
[Test]
public void Test()
{
Template.RegisterFilter(typeof(CategoryFilters));
string template =
@"{% assign colllectioncat = 0 | get_category_by_id %}
{% for category in colllectioncat -%}
{% endfor -%}";
Helper.AssertTemplateResult(" \r\nfoobar", template);
}
private static class CategoryFilters
{
public static IEnumerable<Category> GetCategoryByID(int id)
{
return new[]
{
new Category { Name = "foo" },
new Category { Name = "bar" }
};
}
}
private class Category : Drop
{
public string Name { get; set; }
}