Ternary operator in blueprint?

Is it possible to use something like ternary operator inside a blueprint file. In my note.yml I have a toggle (pinned) that can be true | false. I would like to show this status of the toggle in the blueprint for the pages section (see below in the “info” line). But the current syntax doesn’t show anything:

title: General
icon: 📚

sections:
  pages:
    preset: page
    template: note
    text: " {{ page.title.upper }} "
    info: " {{ page.pinned ? '📌' : '' }}   | {{ page.date.toDate('Y-m-d') }}"

I figured it out through extending the page model. For reference purpose, I’ve created a note.php inside the models folder with following code:

class NotePage extends Page {
  public function isPinned()
    {
        return $this->pinned() == "true" ? "📌" : "";
    }
}

And in the blueprint:
info: " {{ page.isPinned }}"

Still, would be helpful if someone knows if something like a ternary works in the query language?

Nope, there’s no flow control in the query language. I think the idea is to keep it as simple as possible and move every kind of logic into the model. Actually you probably want to have something like a panelInfo function in the model and also move the date stuff there.

Otherwise, if you really want to, I guess you could create a custom field method in a plugin that does your logic, then use it in the blueprint like this

info: " {{ page.pinned.whenTrue('📌') }} | {{ page.date.toDate('Y-m-d') }}"
1 Like