Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Properties are specified in the template using a Property directive. For example, this directive specifies a property named Key which accepts a string value:

...

<%@

...

Property

...

Name="Key"

...

Type="System.String"

...

%>

...

The value that the user enters for the Key property will be inserted into the template output any place that the property name appears surrounded by the special characters <%= %>. For example, consider this template:

...

<%@

...

CodeTemplate

...

Language="VB"

...

TargetLanguage="VB">

...


<%@

...

Property

...

Name="Key"

...

Type="System.String"

...

%>

...


'

...

The

...

key

...

is

...

<%=

...

Key

...

%>

...

If the user enters Ham for the value of the Key property, then the output of this template would be:

...

...

'

...

The

...

key

...

is

...

Ham

...

Properties in CodeSmith can be simple or very complex. You can define enumerated properties that allow the user to choose from a predefined selection of values. You can use CodeSmith's SchemaExplorer to fill properties from database objects. You can create properties based on the contents of an XML file, or even define your own custom properties complete with custom dialog boxes for user property editing.