LINQ - Can we create a static valued array in aspose words template

Can we create a static valued array in aspose words template and assign it var tag?
for example : <<var [test = new string[]{"one", "two"}]>>
Is it possible to create or is there any other alternative?
I can see that from WORDSNET-15836 this feature has been added. But I can’t find any documentation for reference.

@vasanth18

Can you please clarify what you mean by ‘static valued array’ in the context of Aspose.Words template? Are you looking for a specific implementation or example?

I wanted to create an array or list in template file and assign it to a variable tag

@vasanth18 Yes, you can use the above mentioned syntax in your template. For example:

<<var [test = new string[]{"one", "two"}]>>
<<foreach [val in test]>>
    <<[val]>>
<</foreach>>

the issue WORDSNET-15836 has been resolved in 21.7 version of Aspose.Words.

@alexey.noskov - But when using this syntax I am getting error as below,

java.lang.IllegalStateException: An error has been encountered at the end of expression ‘test = new string[]’. A type identifier is expected.

Can you pls advice on this. Thanks.

Using Aspose.Words version 23.5 for Java

@vasanth18 In Java there must be String instead of string:

<<var [test = new String[]{"one", "two"}]>>
<<foreach [val in test]>>
    <<[val]>>
<</foreach>>

1 Like

@alexey.noskov Thanks it worked!

1 Like