Conditional Logic
Text Editor Integration [Top]
Webgenz allows you to use your favorite text editor to edit the Content Files and Templates
that are part of a Webgenz Project. To configure your favorite text editor for use with Webgenz,
go to the "Tools -> Options" screen, select the "Applications" tab, and enter the path of you text editor
(for more detailed instructions, see Step 1 of Getting Started).
In addition, you can configure Webgenz to open your text editor and place the cursor at the start of
the Macro definition that you wish to edit. (Note: this feature was introduced with Webgenz 5.6.4. If you
are using an older version, please upgrade). This feature is used when you have the "Show Macros" Display
Option selected and you double-click on a specific Macro in the Macros listbox. If you are using this feature,
Webgenz will open the Content File to the exact spot where the Macro is defined.
In order to use this feature, you must be using a text editor that supports a command line option for
opening a file to a specific line number. (One of my favorite text editors that supports this feature is
EditPlus). If your text editor supports this type of command line option,
you need to enter the specific command line parameters in the "Editor" section of the "Tools -> Options -> Advanced" screen in Webgenz.
For example, the command line option for opening a file to a specific line number using EditPlus is:
-cursor %LINE%:1
Webgenz will automatically replace %LINE% with the line number of the Macro definition.
Version Control Software Integration [Top]
You can configure Webgenz to work with any version control software that provides a command line
interface, such as Perforce or Visual Source Safe.
To configure Webgenz for use with version control software, you define custom
actions for the pop-up menus that are associated with the Documents, Content Files, and Templates
listboxes. These actions are defined on the "Tools -> Options -> Pop-Up Menus" screen. After doing this,
you simply right-click on a file to access the pop-up menu that will
allow you to synchronize the file or check out the file.
Setup custom pop-up menus on the Program Options screen to provide command line access to version control
software
Pop-up menus provide integration with version control software
Parameter Passing To Macros [Top]
Here's a simple example of a Webgenz Macro that can be used throughout your site. This
is a great example of how you can pass parameters to Webgenz Macros.
Most web developers are familiar with using transparent "spacer" GIFs to control the layout of
items on a page. With Webgenz, you can create a general purpose Macro for this type of spacer
GIF. The Macro would be defined as follows:
[@SPACER(@w:1)(@h:1)]:
<IMG SRC="images/space.gif" WIDTH="(@w)" HEIGHT="(@h)" ALT="">
[@]
You can call this Macro with a width and/or height parameter to set the width and/or height of the spacer. If
you don't pass in either parameter, the width and height will default to 1. Here are a few examples of how you might
reference this Macro:
[@SPACER(@w:600)]
[@SPACER(@h:10)]
[@SPACER(@w:10)(@h:10)]
Subclassing Macros [Top]
Webgenz allows Content Files to be structured into an inheritance hierarchy (see the discussion of
the Project Definition File for details on how this is implemented).
Accordingly, Macros can be shared across a defined set of HTML documents or the entire Project.
This is a powerful feature that facilitates code reuse while allowing you to "scope" Macros so that your
Project remains manageable.
"Subclassing" refers to the ability to take existing, inherited Macro definitions and "extend" or add to
them. Webgenz supports this with the Advanced Macro Tag [@^MACRO_NAME] (note the use of the ^).
The following code is an example of using this Advanced Macro Tag to subclass a Global Macro.
Assume there is a Global Macro defined as follows:
[@JAVA_SCRIPT]:
function showMessage(message)() {
alert(message);
}
[@]
Now, a Macro defined in "local" Content File can subclass the Global Macro definition with the following
Macro definition:
[@JAVA_SCRIPT]:
[@^JAVA_SCRIPT]
function popWin(url) {
window.open(url, 'newWindow', 'toolbar=1,status=1,menubar=1,resizable=1');
}
[@]
In this example, the resulting value of the [@JAVA_SCRIPT] Macro is:
function showMessage(message)() {
alert(message);
}
function popWin(url) {
window.open(url, 'newWindow', 'toolbar=1,status=1,menubar=1,resizable=1');
}
The use of the Advanced Macro Tag [@^JAVA_SCRIPT] instructs Webgenz to search for the
Macro [@JAVA_SCRIPT] starting from the next more general Content File in the inheritance hierarchy.
In this example, [@^JAVA_SCRIPT] would be replaced by the Global Macro [@JAVA_SCRIPT].
Note: To start the search two levels up in the hierarchy you would use the Macro Tag [@^^JAVA_SCRIPT],
and so on. Generally speaking, you should only use Macro Tags with more than one "^"
(i.e. [@^^JAVA_SCRIPT]) on rare occasions, if at all.
Conditional Logic [Top]
Webgenz provides basic support for conditional logic that can be used to
selectively include blocks of HTML code in a document. This is accomplished in the following ways:
- If Webgenz finds a blank value for a Macro, Webgenz will remove the entire line that contains the Macro. This
can be an effective way to conditionally include entire lines of HTML code. Note: if there are certain Macros for
which this behavior should not apply, those Macros can be excluded by listing them in a comma separated list on
the "Conditional Deletion" area of the "Project Properties -> Macros" screen.
- You can use the Advanced Macro Tag [@!MACRO_NAME] (note the use of the !) to comment out entire
blocks of HTML code if a Macro value is blank. When you use this Advanced Macro Tag, you are
telling Webgenz to delete the line where this Advanced Macro Tag appears only
if the value of the macro [@MACRO_NAME] is non-blank. When used with the HTML comment
syntax, you can selectively comment out blocks of HTML code based on the existence of a Macro value.
For example, the following code can be used to comment out the entire TABLE definition if the Macro
[@MY_TABLE_CONTENT] has a blank value.
<!-- [@!MY_TABLE_CONTENT]
<TABLE>
<TR>
<TD>
[@MY_TABLE_CONTENT]
</TD>
</TR>
</TABLE>
--> [@!MY_TABLE_CONTENT]
If the Macro [@MY_TABLE_CONTENT] has a blank value, the result will be:
<!--
<TABLE>
<TR>
<TD>
</TD>
</TR>
</TABLE>
-->
If the Macro [@MY_TABLE_CONTENT] has a non-blank value, the result will be:
<TABLE>
<TR>
<TD>
The value of the Macro is displayed here.
</TD>
</TR>
</TABLE>
To learn more about Webgenz
read the user guide or download a
fully-functional version of Webgenz for evaluation now! Webgenz is
shareware.