string formatting custom object in grantlee

Sandro Knauß sknauss at kde.org
Wed Jan 27 03:15:19 GMT 2021


On Dienstag, 19. Januar 2021 00:52:50 CET Daniel Poelzleithner wrote:
> Hi,
> 
> I just added grantlee to the mixxx dj software for file formatting and
> maybe some other features soon and have to say: grantlee is really nice.

Nice. I really also wanted to look into mixxx to finish mpris interface for it, 
that looks a little bit stalled. 

> I this works nicely if I write "{{ track.key.traditional }}", but I
> would also like that {{ track.key }} becomes a valid string.

I think it is possible, but never used it myself. I you guess, that you want 
use the GRANTLEE_BEGIN_LOOKUP macro:

GRANTLEE_BEGIN_LOOKUP(Key)
if (property.isEmpty()) {
  return object.magicResult();
} 
return object.property(property);
GRANTLEE_END_LOOKUP

you find some examples here:
https://invent.kde.org/pim/messagelib/-/blob/master/messageviewer/src/header/
grantleeheaderformatter.cpp#L130

hefee




More information about the kde-pim mailing list