M2doc: Generation Result of Template Method Differs From Expression


as can be seen in the attached Word there seems to be a difference in the result generated by a template compared to when the same expression is used directly. It should not be, should it? It is quite hard to find - isn’t it a bug?

M.BUG_GenerationResultOFTemplateMethodDiffersFromExpression.docx (19.5 KB)

A template construct returns a part of a MS Word document and not a String. Even if the inserted text is ‘1’ the type returned by the template construct is not String.
So the first test return false as expected.

So then how template construct could be used to test (or compare) the results and to reuse code in such situations? This is a very basic need. Otherwise the template becomes full of identical repeating if elseif … endif .

For the moment the idea was to be able to factorize the generation of parts of the document. For the factorization of navigation, we rely on Java services. But with template generation solution, we usually find the concept of queries that is exactly what your a looking for.
M2Doc doesn’t implement such mechanism yet, but I opened an issue:

Could you be more elaborate on what kind of queries in this context (and what is the equivalent in Acceleo)? Cause I am not sure I know what you have actually meant.

It’s a AQL query wrapped in a function. It could be something like:

{m:query myQuery(param1 : Integer, param2 : Integer) : Integer =
     parm1 + param2

And an example in Acceleo 4. Note that in Acceleo 4 there is a visibilite for inheritance and import that is not needed at the moment for M2Doc.
There is a fonctional if in AQL, see the syntax reference.

Yes, the " if expression then expression else expression endif - conditional expression - if eClass.abstract then ‹blue› else ‹red› endif" AQL syntax would be very usable - but it seems it does not work in m2doc as of now as I have found out already -will it be supported in the coming release?

The “AQL query” is then actually a function which might or might not contain a AQL query. Yes, this would e very usable as already explained above.

I don’t know when I will implement the query feature. For the moment I’m only tracking it on the project github. If you want to finance the development of this feature you can contact Obeo. For the moment no new developments are planed on M2Doc.