Page 1 of 1

use of environment variables in templates

Posted: Thu Feb 06, 2014 3:57 pm
by emmam
Hi all,

I'd like to use environment variables with code templates and templates. For example : when creating a new file from a template, the name of the user is in a <user>name</user> element. Aren't the username in the system propreties or the operating sytstem properties ?

I admit I don't quite get the documentation of http://www.oxygenxml.com/doc/ug-editor/ ... ables.html
and especially this :
${env(VAR_NAME)} - Value of the VAR_NAME environment variable. The environment variables are managed by the operating system. If you are looking for Java System Properties, use the ${system(var.name)} editor variable;
${system(var.name)} - Value of the var.name Java System Property. The Java system properties can be specified in the command line arguments of the Java runtime as -Dvar.name=var.value. If you are looking for operating system environment variables, use the${env(VAR_NAME)} editor variable instead;
Could you provide one or two examples ?

thanks

emma

Re: use of environment variables in templates

Posted: Thu Feb 06, 2014 4:29 pm
by Radu
Hi Emma,

System properties and environmental variables are not the same thing.
If you want to see a list of all system properties and values you can go to the Oxygen Help->About dialog and look in the System properties tab.
If you want a list of environment variables and you are on Windows you can open a command line outside of Oxygen and type SET.

Basically for your use case both of these options would work:

Code: Select all

<user>${system(user.name)}</user>

Code: Select all

<user>${env(USERNAME)}</user>
Regards,
Radu

Re: use of environment variables in templates

Posted: Thu Feb 06, 2014 5:04 pm
by emmam
ok thanks a lot !
${system(user.name)}</user> works fine but not ${env(USERNAME)}</user> : is it because I'm on mac os ?

best regards

emma

Re: use of environment variables in templates

Posted: Fri Feb 07, 2014 9:25 am
by Radu
Hi Emma,

Right, the environmental variables differ from one operating system to another. But most of the Java system properties do not so they are better in this regard, if you want to share your customized template with some one else who works on Windows or Linux.

Regards,
Radu