May m:template be used in the middle of a m2doc template or just at its beginning?

Hello,

In an m2doc template, a m:let X preceding any m:template causes Capella to stall already at the moment the m2doc template is opened (the variables X are not used within the template, instead a paramter X is used in accordance with Use of Self variable in template) If the templates are moved at the beginning of the m2doc template, it works.

Does it mean, that m:template must always be defined at the beginning of an m2doc template?

(Occured in Capella 4.5.2 and m2doc 3.1.0)

The m:template construct can’t be used in any other M2Doc block. It define a template construct that can be compared to a function in other programming languages. In the body of the template construct only variables declared (parameters) in the in the header can be accessed:

m:template myTemplate(param1 : String, pram2: String)
  ...
  m:param1 + param2
  ...
m:endtemplate

I would recommend you group all templates declarations at the same place in your document to keep things structured. It can be at the beginning or at the end of the document.