[rt-users] StockAnswers Template Variables

Michael Grubb mgrubb at fifthvision.net
Thu Oct 10 11:48:31 EDT 2002


Apologies,
the README.templates file for some reason did not seem to make it into the
tar ball (yep another goof, so sorry).
However, I have an updated tarball that will probably make it to the
fifthvision.net website this afternoon.

At this time StockAnswers does not support Mason variable substitution.
I do have plans to add this feature, however since we do not use it at
my site it is low on my to do list.  The variable substitution as it stands
provides a way for you to define variables at the top of the stock answer
templates and then use those variables in the body of the template.
When you select a template that has variables defined, you will be prompted
to enter the values, and then those values will be substituted into the
template text.  Both single and multiple(scalar and list) variables
are supported.

Here are a couple of examples.

Example 1: This example shows list variable definition, and
its use.

*-NAMESERVERS-*

The domain you are inquiring about has the following nameservers listed:
 *-NAMESERVERS-*

__END EXAMPLE 1__

In this example we first define the variable *-NAMESERVERS-*
Notice how the * in the definition appears in the first column,
for now the regex will only pickup definitions that appear in the first column.
Also notice how when we use *-NAMESERVERS-* that it is NOT in the first column,
make sure of this as if you don't the template won't work as expected.
(See Note 1)
This template when chosen will cause the stockanswers module to display a form
with a single field NAMESERVERS the field is a <TEXTAREA> control because 
NAMESERVERS was defined as a list variable, in this <TEXTAREA> control
you should put one value per line.  You can also see the template below,
showing where the values will be inserted, sans the variable definition lines.
Now the line that uses the *-NAMESERVERS-* variable will be substituted for the
values that were supplied by the user. So lets assume the user typed in:
ns1.somedomain.dom
ns2.somedomain.dom

The text inserted into the update box will be:

The domain you are inquiring about has the following nameservers listed:
 ns1.somedomain.dom
 ns2.somedomain.dom

__END__

One thing to note about list variable substitution is that when you use
the variable it will duplicate the entire line that the substitution is 
found on, and then substitute the value. Also you may only substitute
one *-VARIABLE-* per line. See below for a way to get around this.

Example 2: In this example we will show how to use a list variable to
substitute single values multiple times.

Given the Template:

*-PATHS-*

You may install software into the ?-PATHS-? directory,
but never the ?-PATHS-? directory.

__END TEMPLATE__

Here we define a list variable but use it as a scalar variable.
This has the effect of shifting the values off the top of the list to 
substitute the variables.  Given the user input:
/usr/local
/root

Gives the following substitution:

You may install software into the /usr/local directory,
but never the /root directory.

__END__

This gives us the ability to effectively substitute two list variables on one
line.  By defining two list variables and using one list type substitution and
one scalar type substitution it will substitute both lists on the same line.
Given the template:

*-FRUIT-*
*-COLORS-*

The *-FRUIT-* is the color ?-COLORS-?.

__END__

Given the input:
Fruit:
Apple
Orange
Watermellon

Colors:
Red
Orange
Green

You get the following output:

The Apple is the color Red.
The Orange is the color Orange.
The Watermellon is the color Green.

__END__

The thing to remember with this method is that there must be at least the
same number of values in the second list as the first list.
If this is not the case then you get ***NOVALUE*** inserted in place.

Example 3: In this example we substitute a scalar variable.

Given the template:

?-SALUTATION-?
?-NAME-?
?-TOPIC-?
?-CLOSING-?

Dear ?-SALUTATION-? ?-NAME-?,

In response to your support request regarding '?-TOPIC-?',
we would like to inform you that we are currently researching the
issue and will contact you as soon as we have more information.

Thanks for you patience and cooperation.

 ?-CLOSING-?,
 SomeCompany Support
 support at somecompany.dom

__END TEMPLATE__

We would be prompted for four scalar variable values (single text boxes)
Given the following input:

SALUTATION: Mr.
NAME: Somebody
TOPIC: My machine won't boot
CLOSING: Regards

Will give you the following output:

Dear Mr. Somebody,

In response to your support request regarding 'My machine won't boot',
we would like to inform you that we are currently researching the
issue and will contact you as soon as we have more information.

Thanks for you patience and cooperation.

 Regards,
 SomeCompany Support
 support at somecompany.dom

__END__

Note 1:

This is a big annoyance and I plan on fixing this soon,
the people in my organization can't seem to remember this little rule,
So in the next release (Hopefully a 1.0) this will no longer be the case.
Also I'm thinking of changing the variable definition portion some,
although I will probably maintain backwards compatability or provide a script
to update the templates so no worries on this part.

Also any and all suggestions, comments, patches, are welcome.
The biggest thing holding me back from a 1.0 release is the drop down box
type interface, I would like to be able to add support for subdirectories to
it, but I really don't know how to go about it.  As I'm assuming the folks who
would want that are shying away from the javascript requirement.
Also I intend on making the popup interface a little nicer so that
the folders are a little more than just indentation.

Also the email is more or less the README.templates.
So don't sweat over not having it.  Although I will make sure that it is in the
next tarball.

Anyway let me know if I can help, or what you think,

-Micahel

On Wed, 9 Oct 2002 16:36:14 -0400
"Douglas E. Warner" <dwarner at ctinetworks.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I'm having problems trying to figure out how to add variables like the 
> StockAnswers module says I can to my templates.  I'm not very good at Mason 
> yet, so I appologize for not being able to read the code.
> The distribution says to look in README.templates for help, but I can't find 
> that either (I'm using StockAnswers 1.0pre3).
> Specifically (for now), I'm trying to find variables for the requestor name 
> and owner name.
> Maybe an example template for this could help as well.
> 
> - -Doug
> 
> - -- 
> Douglas E. Warner    <dwarner at ctinetworks.com>     Network Engineer
> CTI/PAdotNET         http://ctinetworks.com        +1 717 975 9000
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> 
> iD8DBQE9pJNEJV36su0A0xIRAljMAJ4wwxOlXnRHr9tM3Hp2wVjZvhCbaQCfQVOy
> PPpty40ufFknZSRv6JejMMA=
> =6LZD
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> rt-users mailing list
> rt-users at lists.fsck.com
> http://lists.fsck.com/mailman/listinfo/rt-users
> 
> Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20021010/b9c44bbb/attachment.sig>


More information about the rt-users mailing list