This page created 30 Dec 2020
This article describes some more advanced methods for constructing Templates in Online Repository Assistant (ORA) that extend the techniques described in my article on Intermediate Template Methods. Other articles in my ORA Section cover other topics about using the software.
Topics Included in this Article |
|
Using the output of a Text Template in another Template | |
Text Templates whose output does not appear in the OraPanel | |
Creating a library of Template segments to be used in multiple Templates | |
Additional comments and links on Templates |
My Intermediate Template Methods article describes a variety of useful methods useful in creating Templates to expand the ability of ORA to simplify the process of extracting data from genealogical services and recording it in your genealogy program. This article describes some more advances methods that are useful in constructing more complex Templates, or are useful in avoiding duplication when similar methods are being used in multiple Templates. The methods described here apply equally to Text and Auto Type Templates.
The output of a Text Template can be used as in input field in another Template. This method can be useful when several Templates require the same processing of data, by creating one Template to do that processing then using the result repeatedly. One application of this can be seen in my article on Templates Designed to be Copied.
Several rules apply to use of this method:
For example, suppose there is a field in the record named "Place" and also a Text Template with that name. The Template named "Place" may, but is not required to, use the record field "Place" as a Variable. But any other Template using the Variable "Place" will see only the output of the Template of that name, not the original record field of that name. This means a Text Template can be used to modify the value in a same-named record field and the modified version will be used by the other Templates.
The method described above to create Text Templates that can be used as fields in other Templates produces output that appears in the OraPanel like any other Text Template. That is fine if you might want to sometimes copy and use that output manually, but if not it can cause the OraPanel to expand needlessly. If you prefer the output of a Text Template that will be used only by other Templates not appear in the OraPanel, add the prefix "var." before the name in the heading of that Template, for example:
var.stateThe output of the Template will still be available for use in other Templates even though it does not appear in the OraPanel. The "var."prefix is part of the Template name and must be included in Variables referring to the output of this Template.
When the same segment of Template code is being used in multiple Templates, especially in Templates for different collections, placing that segment in the Template Library can reduce duplication, reduce errors trying to recreate the segment each time it is needed, and simplify future editing. The segment in the Template Library can then be included in other Templates as needed.
The Template Library is accessed by clicking the Templates button in the Library section of the OraSettings page:
In the Edit Library Templates screen that opens, click the Add Template... button to add a new Template, or select the name of an existing one from the drop-down list to edit it:
The Template is then entered in the field in the center of the screen. Library Templates can use the same Variables, Conditional structures, Transforms and other features as Text or Auto Type Templates, as can be seen in the illustration above, which includes a Comment line, and a Variable modified with a Transform
The Template segment in the Library Template is used in a Text or Auto Type Template by referring to it similarly to Variable reference:
[lib.periods]Note that the prefix "lib." must be used with the name of the Library Template to tell ORA that the reference is to a Library Template, and not to a field or Text Template in that collection. Library Templates are not limited to a single collection; they can be used by Text or Auto Type Templates associated with multiple collections.
The "lib." prefix is not entered in the name field when creating a Library Template, it is only used when referring to it in other Templates.
When the Text or Auto Type Template referring to the Library Template is used, the code in the Library Template behaves as if it were copied in the referring Template. In fact, if you use the Test button to test the referring Template and open the Trace window, the Library code will appear in the test window as if it were actually part of the Template being tested.
Library Templates are often used in Templates for different collections, and the names of the fields may differ in the various collections. Thus including the field name directly in the Library Template often does not work. Instead, the names of fields can be entered as parameters in the reference to the Library Template:
[lib.periods:Name]
Note that the field name itself is not enclosed in square bracket, but is entered like a parameter for a Transform.
In the Library Template, the place where the field name is to be used is indicated by a pair of curly brackets enclosing the number 1 for the first parameter, 2 for the second, etc., as shown here:
# adds periods after initials in names when they are not present in the field
[{1}:replace:\b([a-z](?!\.))\b:$1.]
This is the same Template as shown in the illustration above, except the field name "Name" has been replaced with the parameter reference "{1}".
Some examples of use of Library Templates can be seen in my Library Templates Examples article.
This article describes what I find to be as the most useful of the more advanced Template tools. For more information I suggest the following:
ReigelRidge Home | Terry's Tips Home | Contact Terry |
Copyright 2000- by Terry Reigel