use of environment variables in templates

Oxygen general issues.
emmam
Posts: 16
Joined: Sat Jul 28, 2012 11:41 am

use of environment variables in templates

Post 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
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: use of environment variables in templates

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
emmam
Posts: 16
Joined: Sat Jul 28, 2012 11:41 am

Re: use of environment variables in templates

Post 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
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Re: use of environment variables in templates

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply