NAnt SDK Documentation - v0.92

ReplaceTokens Class

Replaces tokens in the original input with user-supplied values.

For a list of all members of this type, see ReplaceTokens Members.

System.Object
   NAnt.Core.Element
      NAnt.Core.Filters.ChainableReader
         NAnt.Core.Filters.Filter
            NAnt.Core.Filters.ReplaceTokens

[Visual Basic]
<ElementName(Name:="replacetokens")>
Public Class ReplaceTokens
    Inherits Filter
[C#]
[ElementName(Name="replacetokens")]
public class ReplaceTokens : Filter

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This filter replaces all token surrounded by a beginning and ending token. The default beginning and ending tokens both default to '@'. The optional BeginToken and EndToken attributes can be specified to change either token. By default string comparisons are case sensitive but this can be changed by setting the optional IgnoreCase attribute to true.

Tokens are specified by using the Token element. It is possible to specify from 1 to n tokens and replacement values. Values can be any valid NAnt expression.

Filters are intended to be used as a element of a FilterChain.

Example

Replace all occurrences of the string @DATE@ with the value of property "TODAY".

    
<replacetokens>
    <token key="DATE" value="${TODAY}" />
</replacetokens>
    
  

Replace all occurrences of the string <DATE> with the value of property "TODAY".

    
<replacetokens begintoken="&lt;" endtoken="&gt;">
    <token key="DATE" value="${TODAY}" />
</replacetokens>
    
  

Requirements

Namespace: NAnt.Core.Filters

Assembly: NAnt.Core (in NAnt.Core.dll)

See Also

ReplaceTokens Members | NAnt.Core.Filters Namespace