question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Verify markup in local functions and @functions codeblocks

See original GitHub issue

We 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:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
NTaylorMullencommented, Jun 5, 2019

@NTaylorMullen I assume this is also the case for .razor files, correct?

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 builder parameter.

0reactions
javiercncommented, Jun 6, 2019

Tried a bunch of stuff. Everything seems to be working just fine.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found