Template Engine language reference > Directives > The #parse directive

The #parse directive
The #parse directive is similar to the #include directive with the addition that Template Engine will parse the external file. This is useful if you have a template fragment that you want to share between templates.
Note:
#parse directives can be recursive, which means the parsed file can in turn contain #parse directives.
Examples
In the following example the file segment.txt is imported to the template using the #parse directive. The content of segment.txt is as follows:
<p>$foo</p>
 
#set($foo='bar')
<html>
<body>
  <p>inline content</p>
  #parse('./segment.txt')
</body>
</html>
<html>
<body>
  <p>inline content</p>
  <p>bar</p>
</body>
</html>
In the following example the file Settings.txt is imported to the template using the #parse directive. The content of Settings.txt is as follows:
#set($color='red')
#set($linetype='dashed')
#set($font='Arial')
#parse('./Settings.txt')
Color is $color
Linetype is $linetype
Font is $font
Color is red
Linetype is dashed
Font is Arial
In the following example the file Calculate.txt is imported to the template using the #parse directive. The content of Calculate.txt is as follows:
#set($result=$a+10)
#set($a=10)
#parse('./Calculate.txt')
The result is $result
The result is 20
 
OpenText StreamServe 5.6 Updated: 2013-03-01