pass plantuml directives as an argument to a macro

+1 vote
asked Jan 26 in Bug by boshka (2,770 points)
recategorized Jan 30 by boshka

Could you check, why this works:

@startuml

!definelong macro(additionalCommands="")

a->b

additionalCommands

!enddefinelong

macro("c->a")

@enduml

while this - does not:

@startuml

!definelong macro(additionalCommands="")

a->b

additionalCommands

!enddefinelong

macro("c->a\nnote right: test")

@enduml

1 Answer

0 votes
answered Jan 26 by Anthony-Gaudino (7,650 points)

When you put c->a\nnote right: test you are defining the name of the second element as a\nnote right: test.

Use this instead:

@startuml
!definelong macro(additionalCommands="")

a->b

additionalCommands
note right: test

!enddefinelong

macro("c->a")
@enduml
commented Jan 26 by boshka (2,770 points)
but if I need to pass multiline commands within one argument? That is, I need to pass "note right: test" as well, and may be some other commands too.

In other words, I want the additionalCommands be interpreted as inserted iuml piece of code.
commented Jan 29 by Anthony-Gaudino (7,650 points)
It seems it's currently not possible to do what you want.

I suggest to have a macro with many optional arguments by now.

Ex:
@startuml
!definelong MACRO(arg1 = "", arg2 = "", arg3 ="")
a -> b

arg1
arg2
arg3
!enddefinelong

MACRO(b -> c, d -> e)
@enduml
commented Jan 30 by boshka (2,770 points)
yes, however, Plantuml team would probably want this to be fixed? :) They just need to properly handle the \n in the argument.
...