0

The 3rd parameter of the generator is a list of arguments.

The documentations says:

If the template which will be called requires more than one argument taken from the model, pass them here.

But how to use this arguments in my template? How to access them?

Ralph

Ralph Bergmann
  • 3,015
  • 4
  • 30
  • 61

1 Answers1

0

Okay I found it... with try and error but not in the documentation :-(

I added one argument to the generator like this:

final List<String> generatorargs = new ArrayList<String>();
generatorargs.add("foo bar");

final DatabaseGenerator generator = new DatabaseGenerator(db, out, generatorargs);
generator.doGenerate(basicMonitor);

And now I can access it like this:

[template public generateElement(aDatabase : Database, foo : String)]

aDatabase is the model and foo is the variable wich contains the 1st argument.

Ralph

Ralph Bergmann
  • 3,015
  • 4
  • 30
  • 61
  • Hi, this third parameter was initially meant for advanced users and we ended up avoiding commenting it as it might cause difficult issues. If what you need to provide to your generator are "string" arguments, you should consider switching to using properties files instead of template parameters. The documentation for that was on the obeo network : http://www.obeonetwork.com/page/acceleo-properties-files . – Kellindil Jan 06 '14 at 08:15
  • Hi, my problem is that this 3rd parameter is a dynamic String. I develop a code generator for Android and for that I need the package from the Android project to put this String in the generated classes. But the developer can change the package. That why I can't store it in the model :-( – Ralph Bergmann Jan 07 '14 at 09:47