Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: zalbina on September 13, 2012, 07:33:35 pm

Title: Code Generation Template
Post by: zalbina on September 13, 2012, 07:33:35 pm
Hello,

I would like to ask how can I call my user defined template from Class or Attribute templates for example. I tried %myTemplate%, but it did not worked.

Thanks.
Title: Re: Code Generation Template
Post by: g.makulik on September 13, 2012, 08:06:47 pm
That's the way it is supposed to 'call' templates. I guess there's either something wrong inside your template or the path where it's called is not reached. Did you try something simple 1st (as just outputtting some comment text)?

Best regards,
Günther
Title: Re: Code Generation Template
Post by: zalbina on September 13, 2012, 09:39:31 pm
I see. The Code inside the template is fine, but when I'm putting it inside the custom template it looks like the template was not called at all. How can I check the pass or what ever can I check?

Thanks.
Title: Re: Code Generation Template
Post by: g.makulik on September 13, 2012, 10:39:06 pm
Type of master (calling) template and custom template need to match.
What did you try? Executing the code directly in the master template works, but replacing it with %custom_template% doesn't? Can you show (excerpts) of the template code?

Best regards,
Günther
Title: Re: Code Generation Template
Post by: zalbina on September 13, 2012, 10:45:49 pm
From class template I call my custom template:

%Class_DDlCLASSG%.
Title: Re: Code Generation Template
Post by: g.makulik on September 14, 2012, 12:56:41 am
Can you show a bit more please, that's not helpful for an analysis (use code formatting for your post).
Although I can see that template types seem to be correct.
Title: Re: Code Generation Template
Post by: zalbina on September 14, 2012, 01:07:28 am
%if classStereotype == "Error" %
%Class_DDLFROMCLASS%
CREATE TABLE %qt%%CONVERT_NAME(className, "Pascal Case","Camel Case")%%qt%
(\n
%list="Attribute" @separator="\n" @indent="  "%
)GO
%endTemplate%
%ClassNotes%
%PI=" "%
%ClassDeclaration%
%ClassBody%
Title: Re: Code Generation Template
Post by: g.makulik on September 14, 2012, 03:00:23 am
So do you see the follow up statements after
Code: [Select]
%Class_DDLFROMCLASS% as expected? Can you show, what you've got inside your custom template?
Title: Re: Code Generation Template
Post by: Eve on September 14, 2012, 08:29:31 am
Double underscore.
Title: Re: Code Generation Template
Post by: g.makulik on September 14, 2012, 09:23:45 pm
Thanks Simon, I didn't spot that. I rarely use custom templates if it can be avoided.
Title: Re: Code Generation Template
Post by: zalbina on September 20, 2012, 12:00:09 am
Ooh, I see. That's my mistake.

Thanks for everybody.