Template Engine language reference > Directives > The #include directive

The #include directive
The #include directive is used to import a resource into the location where the #include directive is defined. The contents of the file is not parsed for TEL grammar. This is useful if you want to include some static boiler-plate content in your output, for example a header or footer that is shared by several templates. If you want Template Engine to parse the contents of the file you must use the #parse directive (see The #parse directive).
The table below shows an example where the file footer.txt is imported to the template using the #include directive. The content of footer.txt is <p>My Footer</p>.
<html>
<body>
  <p>inline content</p>
  #include('./footer.txt')
</body>
</html>
<html>
<body>
  <p>inline content</p>
  <p>My Footer</p>
</body>
</html>
It is possible to include content using four protocols:
Using the file protocol
File is default when no protocol is specified, and is used if the content is available on a local file system or network share. You can specify absolute paths or paths relative to the StreamServer working directory.
Example 27
#include('./mytemplate.html') ##template in working directory
#include('c:\templates\mytemplate.txt')
#include('c:\templates\mytemplate.pdf?outputEnc=base64')
 
Using the http protocol
This protocol is used if the content is available on a web server or content management system.
Note:
Example 28
#include('http://www.example.com/stylesheet.css')
 
Using the resource protocol
This protocol is used if the content is stored as resources in the runtime repository. See Resource output connector in the Connectors documentation or Resource filter in the Design Center documentation for information about how to store the resources.
Template Engine can use the #include directive to include the resources in the output. For example, a StoryTeller document can be wrapped into the output delivered from Template Engine. To reference a resource you can use the GUID of the resource or the name given to the resource (specified in the Resource connector/filter).
Example 29
#include('resource://guid=9E664C0E-807F-024C-8885-659C6EC6E9C8')
#include('resource://name=my_text')
#include("resource://name=$variables.resource?outputEnc=base64")
 
Using the otmm protocol
This protocol is used if the content is an OpenText Media Management (OTMM) asset. To be able to use the otmm protocol you must first create a Media Management connection profile (see the Profile configurations documentation). When you have the connection profile you can reference an asset using the following syntax:
#include('otmm://<profileName>/<reference>')
Where <reference> is either the path to the resource or an ID attribute reference (?id=<GUID of resource>), for example ?id=9E664C0E-807F-024C-8885-659C6EC6E9C8.
Example 30
#include('otmm://gbg/?id=9E664C0E-807F-024C-8885-659C6EC6E9C8')
#include('otmm://gbg/PublicFolders/sign.jpg?outputEnc=base64')
 
Base64 encoding binary data
The #include directive is used to include text resources. To be able to use the #include directive to include binary data, binary resources must be Base64 encoded.
Note:
Example 31
#include('resource://name=my_data?outputEnc=base64')
#include('c:\templates\mytemplate.pdf?outputEnc=base64')
 
The template example below illustrates how to include and base64 encode a PNG image.
<html>
  <body>
    <img src="data:image/png;base64,#include('../data/images/star.png?outputEnc=base64')">
  </body>
</html>
<html>
  <body>
    <img src="data:image/png;base64,iVBORw0AAAANSUhEC … TkSuQmCC">
  </body>
</html>
OpenText StreamServe 5.6.2 Updated: 2018-01-26