A simple block/tag translator example – Adobe Extending Dreamweaver CS4 User Manual
Page 345

339
EXTENDING DREAMWEAVER CS4
Data translators
start = outStr.indexOf('<# if',end);
}
// Return the translated string.
return outStr
}
function getTranslatorInfo(){
returnArray = new Array(7);
returnArray[0] = "Pound_Conditional"; // The translatorClass
returnArray[1] = "Pound Conditional Translator"; // The title
returnArray[2] = "2"; // The number of extensions
returnArray[3] = "html"; // The first extension
returnArray[4] = "htm"; // The second extension
returnArray[5] = "1"; // The number of expressions
returnArray[6] = "<#"; // The first expression
returnArray[7] = "byString"; //
returnArray[8] = "50"; //
return returnArray
}
</script>
</head>
<body>
</body>
</html>
3
Save the file as Poco.htm in the Configuration/Translators folder.
A simple block/tag translator example
To help understand translation, look at a translator that is written entirely in JavaScript, which does not rely on a C
library for any functionality. The following translator example would be more efficient if it were written in C, but the
JavaScript version is simpler, which makes it perfect for demonstrating how translators work.
As with most translators, this one is designed to mimic server behavior. Assume that your web server is configured to
replace the
KENT
tag with a different picture of an engineer, depending on the day of the week, the time of day, and the
user’s platform. The translator does the same thing, only locally.
Create the block/tag translator
1
Create a new blank file.
2
Enter the following code: