在ASP.NET Core中替换@helper

编程入门 行业动态 更新时间:2024-10-28 17:16:48
本文介绍了在ASP.NET Core中替换@helper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

到目前为止,我认为ViewComponent不能解决TagHelper的问题.有什么替代品吗?带有参数并返回HtmlString?

So far, i don't think ViewComponent solves that neither does TagHelper. Is there any replacement to this? Something that takes parameters and returns a HtmlString?

我没有发现任何有害的东西:

I don't see anything harmful with:

@helper foo(string something) { <div>Say @something</div> } var emailbody = classfilenameinAppCodefolder.foo("hello"); //store result in a variable for further processes

就目前而言,我认为它是在RC之前的一个临时删除. github/aspnet/Razor/issues/281 和 github/aspnet/Mvc/issues/1130 好!最好是.我希望有人在努力.如果没有@helper,则构建大型HtmlString或模板"将是一个严重的难题.

For now i believe its a temporary delete before RC. github/aspnet/Razor/issues/281 and github/aspnet/Mvc/issues/1130 Well! it better be. I hope someone is working on it. Without @helper, building large HtmlString or 'template' would be a serious pain.

注意:部分视图似乎无法解决问题.我认为它仅呈现视图,而不会将视图返回到变量.

Note: Partial View doesn't seem to do the trick. I think it only renders views not return view to variable.

第二,App_Code文件夹发生了什么事?

Secondly, what happened to the App_Code folder?

推荐答案

@{ Func<String, IHtmlContent> foo = @<div>Say @item</div>; }

更多推荐

在ASP.NET Core中替换@helper

本文发布于:2023-11-04 12:40:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   ASP   helper   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!