Free Support Forum - aspose.com

IF with Mustache format

Hi,

can i use IF statement in template ONLY using mustache format (i mean without using Word merge fields).
Thanks


Hi Simone,

Thanks for your query. Yes, you can achieve your requirements using Aspose.Words. Please use the value of MailMerge.UseNonMergeFields property as true.

When true, specifies that in addition to MERGEFIELD fields, mail merge is performed into some other types of fields and also into "{{fieldName}}" tags.

Please read following documentation link for your kind reference.
http://www.aspose.com/docs/display/wordsjava/Mail+Merge+using+%27Mustache%27+Template+Syntax

Hope this helps you. Please let us know if you have any more queries.

Sorry, i didn’t understand.
Could you please send me an example of what to write in the template ? Thanks

Hi Simone,

Thanks

for your query. The MailMerge.UseNonMergeFields property is used for mail merge fields with Mustache syntax. Aspose.Words does not evaluate IF with Mustache syntax.

It would be great if you please share some more detail about your query what exact you want to achieve using Aspose.Words. We will then provide you more information about your query.

Hi,


i only like to print something in the generated document if a condition is true, but without using word merge field “IF”.

The question is: is it possible to do it with mustache format only ? without mixing template with word merge fields ?

Thanks
Hi Simone,

Thanks

for sharing the detail. Aspose.Words does not provide the requested feature.

It would be great if you please create a template document with IF field using mustache syntax along with expected output document. Please share these documents here for our reference. We will then log this feature request in our issue tracking system according to your requirements.

Hi, i’ve attached the template with the use of IF with mustache format i need.

It could be used not only with mustache format, like tableStart/foreach…

I think it would be useful for a lot of people, because permits to put more logic on the template and not only in the model. And it’s very simple and easy to use !

Thanks

Hi Simone,


Thanks
for sharing the detail. I have logged this feature request as WORDSNET-11812 in our issue tracking system. Our development team will look into the
possibility of implementation of this requested feature. Once we have
any information about this feature, we will update you via this thread.

Please let us know if you have any more queries.

Any news about this issue ? Are you going to implement it in the next version ?
Thank you very much.

Hi Simone,


Thanks
for your inquiry. I regret to share with you that the implementation of
this feature has been postponed. We will inform you as soon as there are
any further developments.

We apologize for your inconvenience.

Hi, still no news about this issue ? Are you going to implement it ? thanks

Simone

Hi Simone,


Thanks for your inquiry. We have introduced new reporting engine named ‘LINQ Reporting Engine’. This new reporting engine will fix the issue which you are facing. Please read the detail from here:
http://www.aspose.com/docs/display/wordsjava/LINQ+Reporting+Engine+Programmers+Guide

Here is the template syntax description for your reference:

<<if [conditional_expression1]>>
template_option1
<<elseif [conditional_expression2]>>
template_option2

<>
default_template_option
<>

The implementation of this new
reporting engine is included in next version of Aspose.Words v15.5.0.
Hopefully, the next version of Aspose.Words will be available at the start of next week.

Thanks you very much ! I’m very happy about this new report engine.
It seems really what i was searching for !

Will it replace mailmerge with mustache format ?

I’m impatient to give a try to it.

Great work !

Simone

Does it work with objects implementing IMailMergeDataSourceRoot, IMailMergeDataSource ?

What about the cleanup options ? How is it possibile to specify them ?

Thanks

Simone

Hi Simone,


Thanks for your inquiry.
simone.padovan:

Will it replace mailmerge with mustache format ?

No, the new reporting engine has its own syntax. Please read about template syntax from here:
http://www.aspose.com/docs/display/wordsjava/Template+Syntax

You can use different document blocks to represent the same data depending on a condition with the
help of conditional blocks. A conditional block represents a set of template options, each of which is
bound with a conditional expression. At runtime, these conditional expressions are sequentially
evaluated, until an expression that returns true is reached. Then, the conditional block is replaced with
the corresponding template option populated with data.

A conditional block can have a default template option that is not bound with a conditional expression.
At runtime, this template option is used, when none of conditional expressions return true. If a default
template option is missing and none of conditional expressions return true, then the whole conditional
block is removed during runtime.

You can use the following syntax to declare a conditional block.

<<if [conditional_expression1]>>
template_option1
<<elseif [conditional_expression2]>>
template_option2

<>
default_template_option
<>

Note – A conditional expression must return a Boolean value.

simone.padovan:

Does it work with objects implementing IMailMergeDataSourceRoot, IMailMergeDataSource ?
What about the cleanup options ? How is it possibile to specify them ?

The new reporting engine IMailMergeDataSource

In new reporting engine the dataSource is an object providing a data to populate the specified template. The object must be of one of the following types:

  • A traditional mail merge data source (see “Working with Traditional Mail Merge Data Sources” for more information)
  • An object of a custom visible type (see “Working with Types” for more information)

I suggest you please read following documentation links for your kind reference.
http://www.aspose.com/docs/display/wordsjava/LINQ+Reporting+Engine+API
http://www.aspose.com/docs/display/wordsjava/Appendix+A.+Enumeration+Extension+Methods
http://www.aspose.com/docs/display/wordsjava/Appendix+B.+Technical+FAQ
http://www.aspose.com/docs/display/wordsjava/Appendix+C.+Typical+Templates

The issues you have found earlier (filed as WORDSNET-11812) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for .NET 18.12 update and this Aspose.Words for Java 18.12 update.