1

Resolved

Provide a way to clear a RazorTemplateBase's _generatingEnvironment

description

I want to be able to use a template in a loop, like so:
@{ var fooView = new FooView(); } <!-- FooView is a compiled template that outputs a li -->
<ul>
    @foreach (var foo in foos) {
        @{
            fooView.Clear(); 
            fooView.Foo = foo;
        }
        @fooView.TransformText()
    }
</ul>
The lack of a Clear() method means that each time I call TransformText() the internal StringBuilder (_generatingEnvironment) just keeps appending new <li>s.

comments

pranavkm wrote Dec 20, 2012 at 5:54 PM

Fixed in changeset 8c3c1f93e8dd

davidebbo wrote Dec 20, 2012 at 8:24 PM

Version 1.5.1 of RazorGenerator.Templating is now up on NuGet with this change.