[Fixes #691] Use WriteAttributeTo when TextWrites is not null
This commit is contained in:
parent
5ca09d0b10
commit
6cd13c441e
|
|
@ -368,7 +368,16 @@ namespace Microsoft.AspNetCore.Razor.CodeGenerators.Visitors
|
|||
|
||||
Accept(chunk.Children);
|
||||
|
||||
Writer.WriteMethodInvocation(Context.Host.GeneratedClassContext.EndWriteAttributeMethodName);
|
||||
if (!string.IsNullOrEmpty(Context.TargetWriterName))
|
||||
{
|
||||
Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.EndWriteAttributeToMethodName)
|
||||
.Write(Context.TargetWriterName)
|
||||
.WriteEndMethodInvocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
Writer.WriteMethodInvocation(Context.Host.GeneratedClassContext.EndWriteAttributeMethodName);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Visit(SectionChunk chunk)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bf45c2508895b4b9b3579bc193e7a0167ccdbdfb"
|
||||
#pragma checksum "Sections.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ec9a74381c339244a887565526c11056ece494a3"
|
||||
namespace TestOutput
|
||||
{
|
||||
using System;
|
||||
|
|
@ -25,25 +25,36 @@ namespace TestOutput
|
|||
WriteLiteral("\r\n<div>This is in the Body>\r\n\r\n");
|
||||
Instrumentation.EndContext();
|
||||
DefineSection("Section2", async(__razor_section_writer) => {
|
||||
Instrumentation.BeginContext(99, 39, true);
|
||||
WriteLiteralTo(__razor_section_writer, "\r\n <div>This is in Section 2</div>\r\n");
|
||||
Instrumentation.BeginContext(99, 10, true);
|
||||
WriteLiteralTo(__razor_section_writer, "\r\n <div");
|
||||
Instrumentation.EndContext();
|
||||
BeginWriteAttributeTo(__razor_section_writer, "class", " class=\"", 109, "\"", 128, 2);
|
||||
WriteAttributeValueTo(__razor_section_writer, "", 117, "some", 117, 4, true);
|
||||
#line 8 "Sections.cshtml"
|
||||
WriteAttributeValueTo(__razor_section_writer, " ", 121, thing, 122, 7, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttributeTo(__razor_section_writer);
|
||||
Instrumentation.BeginContext(129, 29, true);
|
||||
WriteLiteralTo(__razor_section_writer, ">This is in Section 2</div>\r\n");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
);
|
||||
Instrumentation.BeginContext(141, 2, true);
|
||||
Instrumentation.BeginContext(161, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
DefineSection("Section1", async(__razor_section_writer) => {
|
||||
Instrumentation.BeginContext(162, 39, true);
|
||||
Instrumentation.BeginContext(182, 39, true);
|
||||
WriteLiteralTo(__razor_section_writer, "\r\n <div>This is in Section 1</div>\r\n");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
);
|
||||
Instrumentation.BeginContext(204, 2, true);
|
||||
Instrumentation.BeginContext(224, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
DefineSection("NestedDelegates", async(__razor_section_writer) => {
|
||||
Instrumentation.BeginContext(232, 2, true);
|
||||
Instrumentation.BeginContext(252, 2, true);
|
||||
WriteLiteralTo(__razor_section_writer, "\r\n");
|
||||
Instrumentation.EndContext();
|
||||
#line 16 "Sections.cshtml"
|
||||
|
|
@ -59,17 +70,17 @@ namespace TestOutput
|
|||
#line hidden
|
||||
|
||||
item => new Template(async(__razor_template_writer) => {
|
||||
Instrumentation.BeginContext(268, 6, true);
|
||||
Instrumentation.BeginContext(288, 6, true);
|
||||
WriteLiteralTo(__razor_template_writer, "<span>");
|
||||
Instrumentation.EndContext();
|
||||
Instrumentation.BeginContext(275, 4, false);
|
||||
Instrumentation.BeginContext(295, 4, false);
|
||||
#line 16 "Sections.cshtml"
|
||||
WriteTo(__razor_template_writer, item);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
Instrumentation.EndContext();
|
||||
Instrumentation.BeginContext(279, 7, true);
|
||||
Instrumentation.BeginContext(299, 7, true);
|
||||
WriteLiteralTo(__razor_template_writer, "</span>");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<div>This is in the Body>
|
||||
|
||||
@section Section2 {
|
||||
<div>This is in Section 2</div>
|
||||
<div class="some @thing">This is in Section 2</div>
|
||||
}
|
||||
|
||||
@section Section1 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue