我的意思是,现在我们已经采取了所有这些措施,尽可能使用现代模板引擎将您的 html 标记与代码分离(在过去,程序员通常只是在 php 中保持连接字符串,这很糟糕。)
然后我查看了一个同事生成 html 表的代码,它看起来像:
<% Html.Grid(Model).Columns(column => {
column.For(x => Html.ActionLink("Edit", "Edit", new { id = x.Id })).Attributes(width => "30px").DoNotEncode();
column.For(x => Html.ActionLink("Delete", "Delete", new { id = x.Id }, new { @class = "delete" })).Attributes(width => "95px").DoNotEncode();
column.For(x => x.Id).Named("Code");
column.For(x => x.Name).Named("Name").HeaderAttributes(align => "left");
column.For(x => x.CPF).Named("CPF");
})
.Attributes(width => "100%", border => "0", cellpadding => "0", cellspacing => "0", @class => "data-table")
.Empty("No users found!")
.RowStart(row => string.Format("<tr class='row{0}'>", row.IsAlternate ? "-alternating" : ""))
.Render();
%>
他觉得好看,我觉得挺丑的,想知道更多人的看法。