Verify markup in local functions and @functions codeblocks
See original GitHub issueWe added the ability to provide markup in local functions i.e.
@{
void Foo()
{
<p>The time is @DateTime.Now</p>
}
}
@{ Foo(); }
and in @functions blocks:
@functions {
void Foo()
{
<p>The time is @DateTime.Now</p>
}
}
@{ Foo(); }
This feature set should be functionally validated for Razor views. To make this set of features work in Components is a little more time consuming and not fully designed. i.e. you need to pass in extra parameters into your methods in order to utilize markup in the @functions block. Despite it not being fully designed it should still work in Components as well.
Copied from: https://github.com/aspnet/Release/issues/335 Please see referenced issue fore more details.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Show local variables in the debugger
Show local variables in the debugger. ... If some piece of operations should be reused, turn them to functions. If they happened together, ......
Read more >Add support for markup in local functions and ... - YouTrack
In code blocks, declare local functions with markup to serve as templating methods: But I see that there's better support for markup when...
Read more >Functions — reusable blocks of code - Learn web development
You can check the full list of the built-in functions, as well as the built-in objects and their corresponding methods here. You've also...
Read more >How can I add Razor Markup from a C# Method?
Original Answer. This shows you how to build and display a simple render fragment from markup. It may help. @page "/Test" <h3>Test8</h3> ...
Read more >Razor syntax reference for ASP.NET Core
Razor is a markup syntax for embedding .NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, however that experience is less fleshed out so in order to have markup in local functions/codeblocks in .razor files you must pass in a
RenderTreeBuilder builderparameter.Tried a bunch of stuff. Everything seems to be working just fine.