Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Polarsys » M2Doc » Use of Self variable in template
Use of Self variable in template [message #1833101] Fri, 02 October 2020 09:20 Go to next message
Julien Morane is currently offline Julien MoraneFriend
Messages: 19
Registered: December 2019
Junior Member
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,

Re: Use of Self variable in template [message #1833111 is a reply to message #1833101] Fri, 02 October 2020 12:10 Go to previous messageGo to next message
Yvan Lussaud is currently offline Yvan LussaudFriend
Messages: 63
Registered: July 2009
Member
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.
Re: Use of Self variable in template [message #1833113 is a reply to message #1833111] Fri, 02 October 2020 12:28 Go to previous message
Julien Morane is currently offline Julien MoraneFriend
Messages: 19
Registered: December 2019
Junior Member
Thank you very much Yvan for that quick answer (I had forgotten the capellamodeller on the second part of my message) !

Rgds

[Updated on: Fri, 02 October 2020 12:28]

Report message to a moderator

Previous Topic:how to edit "Allocating Actor/Component (computed)" with M2DOC
Next Topic:how to edit "Requirements Viewpoint" requirements with M2DOC
Goto Forum:
  


Current Time: Thu Dec 01 01:22:30 GMT 2022

Powered by FUDForum. Page generated in 0.02605 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top