我对 MVC 很陌生,刚刚阅读了一篇关于助手的文章。现在我在视图上有这段代码:
<div class="display-label">Ingredients:
<% foreach (var e in Model.Products_Ingredients)
{%>
<%: e.Ingredient.Name%><br />
<%: e.Percentage%>
<%if (e.Percentage != null)
{%>
%
<%}%>
<br />
<%}%>
</div>
我该如何继续并创建一个 Helper 来用更简单的代码替换该代码,例如:
<div class="display-label">Ingredients: <%: MyHelpers.Ingredients %> </div>
谢谢!