-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Implementation of RenderFragment<T> #15829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
just one more thing.
it can be anything, as long as the property is a RenderFragment! |
I really like this! Does this also work with server side? |
Hi @uazo - I'm currently looking at implementing
We'll do more with this, but I'm starting here for now since this is an existing Razor feature that isn't yet supported in Blazor land. Is there any overlap of this with what you've done? |
Hi @rynowak . My work allowed a way to define a I think, however, that a syntax like this would allow the use of any variable name.
Also, what about the sintax for the html? Like this? Is it supported?
I have updated branch with master, so you can see only my changes |
@LunicLynx yes, just because is a compiler time feature |
I agree that something like that would be ideal but it would require changes to the core of Razor to work well. We'll be making changes to Razor to improve Blazor's scenarios as part of 3.0 but the time frame for making that available in editors is somewhat distant.
The PR I sent yesterday adds support for passing a template 'inline' as a component parameter. This is also something that regular Razor doesn't support (templates inside attributes) and so there is some buggy behavior around completion and colorization. For instance colorization of markup inside the attribute doesn't work. |
I would like to submit a possible implementation of
RenderFragment<T>
to the Blazor community. Source code is here: https://github.com/uazo/Blazor/tree/dev-experimental-templated-component.This time before doing a pull request I ask here :)
An example is worth a thousand words:
will be renderer as
and to use simple as
a complete example is provided in StandaloneApp.
I'm using
<ComponentTemplateTest.Template>
to define the value of RenderFragment property but it isn't mandatory. We can use only<Template>
but if there is a component with that name it will not work. In this way the possibility of homonyms is excluded.The attribute
WithParams
is used to specify the name of the local variable, so that it is the developer who uses the component to decide the name.The changes are all in the extension.
I have not introduced any breaking changes, so ChildContent keeps working.
The test cases are missing, but I could not find those related to ChildContent to understand how they work (never done test cases before!)
Unfortunately there are some imperfections in intellisense that I can not fix:
I can not stop showing all the standard helpers tags (defined in BindTagHelperDescriptorProvider.cs) for the new template tags. I think it's a limitation of TagMatchingRule that does not allow to define tags to be excluded. If "Microsoft.VisualStudio.Web.Editors.Razor" would expose "TagHelperScriptOrStyleTagNameService" I could edit "TagHelperFactsService" and introduce new rules, but I did not understand how.
When writing
<ComponentTemplateTest.Template>
Intellisense shows comments in the popups that I can not hide.However it seems to work.
I would be happy to contribute to this wonderful project: if there is something to change or improve I am available for sure.
The text was updated successfully, but these errors were encountered: