Question on new preprocessor
coryodaniel opened this issue · 2 comments
coryodaniel commented
I've upgraded to using the new preprocessor and Im experience a "lost of functionality" with converting from !define to !function.
Given these two implementations:
!define OldComponent($alias, $label, $techn) rectangle "==$label\n//<size:$TECHN_FONT_SIZE>[$techn]</size>//" <<component>> as $alias
!unquoted function NewComponent($alias, $label, $techn)
rectangle "==$label\n//<size:$TECHN_FONT_SIZE>[$techn]</size>//" <<component>> as $alias
!endfunction
The OldComponent
would allow adding links to the rectangle, but NewComponent
silently accepts it, but will not render it.
@startuml Basic Sample
!include lib.puml
OldComponent(foo, "Foo", "foo") [["http://example.com/foo"]]
NewComponent(bar, "Bar", "bar") [["http://example.com/bar"]]
@enduml
The image renders fine, but the cmapx renders:
<map id="plantuml_map" name="plantuml_map">
<area shape="rect" id="id1" href="http://example.com/foo" title="http://example.com/foo" alt="" coords="6,8,304,79"/>
</map>
Is this functionality thats no longer available or is there a new way to do something similar?
arnaudroques commented
As general rules, !define should be changed to return function.
So you should have
@startuml
!$TECHN_FONT_SIZE = 14
!define OldComponent($alias, $label, $techn) rectangle "==$label\n//<size:$TECHN_FONT_SIZE>[$techn]</size>//" <<component>> as $alias
!unquoted function NewComponent($alias, $label, $techn)
!return 'rectangle "==' + $label + '\n//<size:' + $TECHN_FONT_SIZE + '>[' + $techn + ']</size>//" <<component>> as ' + $alias
!endfunction
OldComponent(foo, "Foo", "foo") [["http://example.com/foo"]]
NewComponent(bar, "Bar", "bar") [["http://example.com/bar"]]
@enduml
Which is rendering this.
Hope this helps!
Tell us if you find other issue with converting.
coryodaniel commented
Awesome, much appreciated!!!