小智 6
您在问题中描述的标记与ASP.NET无关.它们是T4模板标记语法的示例.T4模板在Visual Studio中进行转换,可用于创建任何类型的文件,但最常见的是它们用于代码生成.
<#= #>执行标记中的代码并返回文本结果.例:
// in this example, TargetNamespace is set to "MuhNamespace"
namespace <#= this.TargetNamespace #> { // outputs: namespace MuhNamespace
Run Code Online (Sandbox Code Playgroud)
<# #>执行代码但返回void.例:
This collection contains the following foos:
<#foreach(var foo in bar){ #>
<#= foo.Name + Environment.NewLine #>
<# } #>
Run Code Online (Sandbox Code Playgroud)
<#+ #>定义可在模板中调用的可重用方法.例如,
This collection contains the following types:
<#foreach(var foo in bar){ #>
<#= GetType(foo) #>
<# } #>
<#+ public string GetType(foo){ return foo.GetType().FullName; } #>
Run Code Online (Sandbox Code Playgroud)
还有更多这些,其中的例子可以在这里找到.
| 归档时间: |
|
| 查看次数: |
649 次 |
| 最近记录: |