StockAnswers Template Variables

-----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@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-----

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 control because
NAMESERVERS was defined as a list variable, in this 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@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@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,

-MicahelOn Wed, 9 Oct 2002 16:36:14 -0400 “Douglas E. Warner” dwarner@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@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@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