Use of Self variable in template

Dear all,

I tried to create template constructs (following https://www.m2doc.org/ref-doc/2.0.2/index.html#template-construct-example). in order to make M2Doc more user-friendly for my colleagues.

My first use would be to create a template that would display a PAB diagram.
For that, I made :

{m:template insertPABdiagram(DiagramName:String)} 

{m:for myRepresentation | self.containedPhysicalArchitectures.ownedPhysicalComponent. representationByDescriptionName('Physical Architecture Blank') }

// then a filtering by name of the diagrams and a display of the diagram
 {m:endtemplate}

However, an error ‘Couldn’t find the “self” variable’ has been raised,.
I was quite suprised that the ‘global’ variable self could not been used in ‘local’ template.

So my first though was to introduce it as a parameter of the functions (which will then be called by DiagramName.insertPABdiagram(self))

However, the {m:template insertPABdiagram(DiagramName:String, self:SystemEngineering)} raised also an error.

Has someome already solved that problem ?

Rgds,

Dear Julien,

In the body of a template construct, only deplared parameters are accessible as variable. In you example you have noly one parameter: DiagramName:String.
You should declare a parameter self (or with an other name) to be able to use it in the template construct body. For instance:

m:template insertPABdiagram(self:capellamodeller:SystempEngineering, DiagramName:String)}

regards,
Yvan.

Thank you very much Yvan for that quick answer (I had forgotten the capellamodeller on the second part of my message) !

Rgds