A simple attribute translator example
To better understand attribute translation, it's helpful to look at an example. The following
translator is Pound Conditional (Poco) markup, a syntax that's somewhat similar to ASP or PHP.
The first step in making this translator work properly is to create a
which prevents Dreamweaver from parsing the untranslated Poco statements.
The following example shows the
<tagspec tag_name="poco" start_string="<#" end_string="#>"
detect_in_attribute="true" icon="poco.gif" icon_width="17"
icon_height="15"></tagspec>
The poco.xml file that contains this tagspec is stored in the Configuration/ThirdPartyTags folder,
along with the icon for Poco tags.
<html>
<head>
<title>Conditional Translator</title>
<meta http-equiv="Content-Type" content="text/html; charset=">
<script language="JavaScript">
/*************************************************************
* This translator handles the following statement syntaxes: *
* <# if (condition) then foo else bar #>
* <# if (condition) then att="foo" else att="bar" #>
* <# if (condition) then att1="foo" att2="jinkies"
* att3="jeepers" else att1="bar" att2="zoinks" #>
*
* It does not handle statements with no else clause.
*************************************************************/
var count = 1;
function translateMarkup(docNameStr, siteRootStr, inStr){
var count = 1;
// Counter to ensure unique mmTranslatedValues
var outStr = inStr;
// String that will be manipulated
var spacer = "";
// String to manage space between encoded attributes
var start = inStr.indexOf('<# if'); // 1st instance of Pound Conditional code
// Declared but not initalized. //
var attAndValue;
for Poco markup:
tagspec
tag for Poco markup,
tagspec
*
*
*
*
*
*
Adding a translated attribute to a tag
341
Need help?
Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?
Questions and answers