4W WebMerge Tag Reference


[WM-Field: fieldName]
[WM-Field: fieldName raw]
[WM-Field: fieldName nolink]

[WM-Field: fieldName maxLen=number]

[WM-Field: fieldName Unicode:language]

[WM-Field: fieldName cgiEncoded] 

[WM-Field: fieldName replace(findString,replaceStr] 

Name: [WM-Field: First_Name]<br />
Tel: [WM-Field: Phone]<br />
Description: [WM-Field: JobDescription raw replace("/","-")]

Product info: [WM-Field: Description maxlen=200]


The [WM-Field] tag is replaced by the contents of the field specified in fieldName.

Using the raw attribute
By default, WebMerge converts field data to HTML. The conversion changes all non-ASCII characters to their corresponding character entity according to the ISO 8859-1 standard. For example, the character "<" becomes "&lt;". This attribute is useful if your database contains some fields whose data is already in HTML format, to prevent WebMerge from altering it for Web display. If your field already contains HTML, you can tell WebMerge not to perform this conversion by using the raw attribute.

Using the nolink attribute
When used in an index template, by default WebMerge generates all WM-Field tags as links to the corresponding detail page. The optional nolink attribute is used in index pages to tell WebMerge to write the tag without linking it to that detail page. If used in a detail page template, the nolink attribute is ignored.

Using the maxLen attribute
The maxLen attribute truncates the text from the specified field to a given length. Text is truncated on word boundaries to preserve readability, and any trunacted text is indicate with the addition of an ellipsis at the end if it. This option can be useful when you want to display a portion of things like long product descriptions.

Using the Unicode attribute
By default, WebMerge assumes that any field data contains 8-bit characters, as is common for English and many other Western languages. But if you database includes fields that use Unicode text (16-bit text used for Japanese, Chinese, and others) you can tell WebMerge to treat the text as Unicode by including the Unicode attribute.

When specifying Unicode, you must also specify a language, which can be any of the following:

Arabic Greek Roman Ukrainian
Bulgarian Hebrew Russian (Cyrillic) Unicode (UTF-16)
Chinese Japanese (Shift-JIS) Russian
English Korean SimpleChinese

For example, using this in a template:

 [WM-Field: MyJapaneseData Unicode:Japanese] 

...will generate the text using the Unicode characters for Japanese.

Using the cgiEncoded attribute
This attribute tells WebMerge to encode the data from the specified field in a format appropriate for sending to a CGI. All spaces are replaced with "+" characters, and all special characters are converted to hex encodings of the form %XX.

For example, if we wanted to send field data to the Google search CGI we could include something like this in our template:

  <a href="http://www.google.com/search?q=
   [WM-Field: MyField cgiEncoded]">Click here</a>

If your field data contained "Fourth World" the generated HTML would be:

  <a href="http://www.google.com/search?q=fourth+world">
   Click here</a>

Since the cgiEncoded attribute controls formatting in links, it cannot be used in conjunction with the raw or nolink attributes.

Using the replace attribute

The replace attribute is a function that tells WebMerge to replace any instances of the string in findString with the value in replaceString for the specified field.

Each findString and replaceString can be any string of characters contained within quotation marks and separated by commas. You can include quote and comma characters by using the contants "quote" and "comma", respectively, concatenating with the "&" character as needed.

For example, if your fied data contained:

  He said Hello World

...then this:

 [WM-Field: MyField replace("Hello World", quote&"Hello"&comma&" World!"&quote)]

...would generate this HTML:

 He said &quot;Hello, World!&quot;

You can have any number of comma-separated find-and replace pairs between the parentheses, each pair separated by semi-colons:

 [WM-Field: MyField replace("find","replace";"/","-")]

Other link attributes
HTML supports a variety of attributes for links, such as specifying a target frame in which to open linked pages. In addition to the WebMerge attributes noted above, you can also include any number of standard link attributes in your index templates, and these will simply be copied into the generated link code. Just include any attributes you want included in your link after any WebMerge attributes.

For example, if your template reads:

[WM-Field: FieldName target="Frame"]

Then the resulting link will read:

<a href="detail.html" target="Frame">FieldData</a>

Note about file names
Remember that if your original field name has spaces in it, most databases will replace spaced with underscores, which is the form WebMerge will expect. So if you have a field named "First Name" in your database, the name you'll use in your tag will be "First_Name".

First introduced in version 1.0.
Version 1.7 introduced the optional raw attribute.
Version 1.8 introduced the optional nolink attribute.
Version 2.1 introduced the optional cgiEncoded attribute.
Version 2.3 introduced the optional replace attribute.
Version 2.5 introduced the optional maxLen attribute.