advertisement

Summary

ORA's Template Library provides a way for users to store frequently-used template text in a library. Each item in the library is a library template that can be used by any collection template. This helps reduce repetition in collection templates.

The Template Library feature is a text pre-processor that modifies the collection template before the usual template processing begins. The text in a library template is inserted into a collection template anywhere the collection template refers to a library template.

The diagram below shows an example of how a collection template is modified by a reference to a library template.

Template Library Example

Editing Templates

You open the Template Library using the [Templates...] button on the OraSettings page to open the Edit Library Templates panel:

Template Library Settings
  • Use the Add Template... button to add a new template to the library. You will be prompted to enter the name of the template.
  • Use the Current Template pull-down menu to select a template to edit. When you choose a template from the pull-down menu, ORA will set the textbox to the text of the template you select.
  • Use the textbox to edit the current template.
  • Use the Rename Template... button to rename the current template. You will be prompted to enter the new name of the template.
  • Use the Delete Template... button to delete the current template from the library. You will be prompted to confirm that you really do want to delete the template.

Template References

To insert a library template into a collection template, you add a library template reference to the collection template. You may add a library template reference to both Text Templates and Auto Type Templates in any collection in any repository.

You may create library templates that are intended for use with only a subset of the collections you use, but that is up to you.

A library template reference uses syntax that is similar to Variable References:

[lib.name]
  • lib. is a special prefix that indicates that the name that follows identifies a library template and not a field value.
  • name is the name of a template in your template library.

Template Contents

A library template may include any template text that you would otherwise include in a Text Template or Auto Type Template:

  • Variables references such as [Name]
  • Conditional expressions such as <Address: [Address]>
  • Assignment References for prompts or other purposes
  • Auto Type Control Sequences
  • Literal Text
  • Comment Lines
  • References to other library templates (Be careful of endless loops!)

Typically, a library template will provide only a portion of the output of the collection template where it is referenced, but how much or how little to specify in a library template is up to you.

Template Reference Parameters

As described above in the Template References section, you add a library template reference to insert a library template into a collection template. The full syntax is:

[lib.name:parameter1:parameter2:...]

You may include zero, one, or more parameters.

To use a parameter inside the library template, enclose the parameter number in braces. For example, to refer to parameter 1, use {1} and to refer to parameter 2 use {2}.

Inside the library template you may provide a default value for a parameter. For example, if parameter 1 is optional and should default to "Record Id", you would use this text in the library template: {1:Record Id}.

Using Field Names as Parameters

To implement a library template that operates on a field that is supplied in a parameter, the library template reference should include the field name and should not enclose the name in brackets.

  • Correct: [lib.County:Birth Place]
  • Incorrect: [lib.County:[Birth Place]]

In the library template, to use the parameter to refer to a field, enclose the parameter reference inside brackets:

[{1}]

After the Template Library pre-processor modifies the template, the resulting text is:

[Birth Place]

In the library template, you may add transform parameters after the reference to the parameter:

[{1}:split:,:2]

After the Template Library pre-processor modifies the template, the resulting text is:

[Birth Place:split:,:2]

Conditional Sections

A library template may include conditional sections that are included only if the associated parameter is provided in the template reference. A conditional section begins with {{n: where "n" is the parameter number. The conditional section ends with the next }} characters.

Conditional sections may not be nested.

Example Template with Conditional Sections

The library template below has six conditional sections that are inserted into the collection template only if the associated parameter (2 through 7) is provided.

<
{{2:<[{2}]>}}
{{3:<[+:{1:, }][{3}]>}}
{{4:<[+:{1:, }][{4}]>}}
{{5:<[+:{1:, }][{5}]>}}
{{6:<[+:{1:, }][{6}]>}}
{{7:<[+:{1:, }][{7}]>}}
>

The template accommodates up to seven parameters where the first is an optional delimiter that defaults to ", " and the remaining six are field names. The template concatenates the fields together using a conditional expression but only includes sub-expressions for fields whose names are included in the template reference.

If the template above was named "concatPlace", you would call it as shown in the examples below. Assume that the fields mentioned in the example have these values:

  • City: Boston
  • County: Suffolk
  • State: Massachusetts
  • Country: (empty)

Example References

[lib.concatPlace::City:State]

Result: Boston, Massachusetts

[lib.concatPlace::City:County:State]

Result: Boston, Suffolk, Massachusetts

  • [lib.concatPlace:; :City:County:State:Country]

    Result: Boston; Suffolk; Massachusetts

  • On This Page