CodeSmith(7)codesmith函数和变量定义

//所有codesmith函数都在script标签里面定义,包括变量

<% @ CodeTemplate Language = " C# "  TargetLanguage = " T-SQL "
        Description
= " Generates a update stored procedure. "   %>
 
-----------------------------------------------------------------
 
--  Date Created:  <%=  DateTime.Now.ToLongDateString()  %>
 
--  Created By:   guojiang
 
-----------------------------------------------------------------
< script runat = " template " >
private   string  outputDirectory  =   " f:\\ " ;
  
public   string  Getstring()
 
{
       
string param ="hehe!";
 
       
return param;
 }

 
script >
<%=
this .Getstring()
%>
<%= outputDirectory %> ;


调用用<% %> 括起来,一般有一个主函数来执行整个模板的函数
<%
this.Getstring();
%>
//取得函数的值
<%=
this.Getstring()
%>

转载于:https://www.cnblogs.com/gjahead/archive/2007/05/17/749772.html

你可能感兴趣的:(CodeSmith(7)codesmith函数和变量定义)