-
The runDefault string specifies when this translator executes. The following list gives the possible string values:
String
Definition
"allFiles"
Sets the translator to always execute.
"noFiles"
Sets the translator to never execute.
"byExtension"
Sets the translator to execute for files that have one of the file extensions that are specified in the extension.
"byExpression"
Sets the translator to execute if the document contains a match for one of the specified regular expressions.
"bystring"
Sets the translator to execute if the document contains a match for one of the specified strings.
Note:
If you set runDefault to "byExtension" but do not specify any extensions (see step 4.), the effect is the same as setting "allFiles". If you set runDefault to "byExpression" but do not specify any expressions (see step 6.), the effect is the same as setting "noFiles".
-
The priority string specifies the default priority for running this translator. The priority is a number between 0 and 100. If you do not specify a priority, the default priority is 100. The highest priority is 0, and 100 is the lowest. When multiple translators apply to a document, this setting controls the order in which the translators are applied. The highest priority is applied first. When multiple translators have the same priority, they are applied in alphabetical order by translatorClass.
The following instance of the getTranslatorInfo() function gives information about a translator for server‑side includes:
function getTranslatorInfo(){ var transArray = new Array(11); transArray[0] = "SSI"; transArray[1] = "Server-Side Includes"; transArray[2] = "4"; transArray[3] = "htm"; transArray[4] = "stm"; transArray[5] = "html"; transArray[6] = "shtml"; transArray[7] = "2"; transArray[8] = "<!--#include file"; transArray[9] = "<!--#include virtual"; transArray[10] = "byExtension"; transArray[11] = "50"; return transArray; }
Dreamweaver performs two translation passes. The first pass goes through all the translators and calls the translateMarkup() functions. After those functions are called, the second pass calls the translateDOM() functions. The dom passed in is the dom to translate. The only edits that are allowed during the second pass are those dealing with translated attributes.
The dom argument.
The sourceStr argument is the same string passed into translateMarkup. It's provided for reference, but all translation should be done on the dom argument, not the sourceStr argument.
translateDOM( dom, sourceStr ); //returns nothing
The following instance of the translateDOM() function hides the tag with ID div1 in the document.
function translateDOM(dom, sourceStr){ var div1 = dom.getAttributeById("div1"); if (div1){ div1.style.display = "none"; } }
The docName argument is a string that contains the file:// URL for the document to be translated.
The siteRoot argument is a string that contains the file:// URL for the root of the site that contains the document to be translated. If the document is outside a site, this string might be empty.
The docContent argument is a string that contains the contents of the document.
The following instance of the translateMarkup() function calls the C function translateASP(), which is contained in a dynamic link library (DLL) (Windows) or a code library (Macintosh) called ASPTrans:
function translateMarkup(docName, siteRoot, docContent){ var translatedString = ""; if (docContent.length > 0){ translatedString = ASPTrans.translateASP(docName, siteRoot, ¬ docContent); } return translatedString; }
For an all-JavaScript example, see A simple attribute translator example or A simple block/tag translator example.
This function translates documents when users are using the Live Data window. When the user selects the View > Live Data command or clicks the Refresh button, Dreamweaver calls the liveDataTranslateMarkup() function instead of the translateMarkup() function.
The docName argument is a string that contains the file:// URL for the document to be translated.
The siteRoot argument is a string that contains the file:// URL for the root of the site that contains the document to be translated. If the document is outside a site, this string might be empty.
The docContent argument is a string that contains the contents of the document.
The following instance of the liveDataTranslateMarkup() function calls the C function translateASP(), which is contained in a DLL (Windows) or a code library (Macintosh) called ASPTrans:
function liveDataTranslateMarkup(docName, siteRoot, docContent){ var translatedString = ""; if (docContent.length > 0){ translatedString = ASPTrans.translateASP(docName, siteRoot, docContent); } return translatedString; }