You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
Tag Helpers can specify content to appear before and after the contents of the HTML element they're operating on. Sometimes however, a Tag Helper will want to generate content that appears before or after the element itself, e.g. the <link> and <script> Tag Helpers in MVC. Currently, that requires them to manually rebuild the original element by suppressing the default output and constructing the original HTML using the information from TagHelperContext and TagHelperOutput. This should be simpler for Tag Helpers to do.
We should add new properties to TagHelperOutput that enable this, e.g.:
<my-tag-helper>
Content in source
</my-tag-helper>
Tag Helper file:
publicvoidProcess(TagHelperContextcontext,TagHelperOutputoutput){varnl= Environment.NewLine;varbr="<br />"+nl;
output.PreElement.Append("This will appear before source element"+br);
output.PreContent.Append(nl+"This will appear before source content"+br);
output.PostContent.Append(br+"This will appear after source content"+nl);
output.PostElement.Append(br+"This will appear after source element");}
Output:
This will appear before source element<br />
<my-tag-helper>
This will appear before source content<br />
Content in source<br />
This will appear after source content
</my-tag-helper><br />
This will appear after source element
The text was updated successfully, but these errors were encountered:
- These two new properties will enable TagHelper authors to render content before and after the TagHelper's HTML element.
- Added tests to correspond with existing test coverage.
- Modified existing tests to double check for TagHelperOutput.Pre/PostElement.
#341
- Added unit tests to validate that the properties were rendered correctly.
- Modified functional tests to utilize PreElement and PostElement.
aspnet/Razor#341
- Added unit tests to validate that the properties were rendered correctly.
- Modified functional tests to utilize PreElement and PostElement.
aspnet/Razor#341
- These two new properties will enable TagHelper authors to render content before and after the TagHelper's HTML element.
- Added tests to correspond with existing test coverage.
- Modified existing tests to double check for TagHelperOutput.Pre/PostElement.
- Refactored all DefaultTagHelperContent pieces of TagHelperOutput to be get only properties.
#341
Tag Helpers can specify content to appear before and after the contents of the HTML element they're operating on. Sometimes however, a Tag Helper will want to generate content that appears before or after the element itself, e.g. the
<link>
and<script>
Tag Helpers in MVC. Currently, that requires them to manually rebuild the original element by suppressing the default output and constructing the original HTML using the information fromTagHelperContext
andTagHelperOutput
. This should be simpler for Tag Helpers to do.We should add new properties to
TagHelperOutput
that enable this, e.g.:Example
Source file:
Tag Helper file:
Output:
The text was updated successfully, but these errors were encountered: