String helper to substr a part from a longer string?

Isn’t there a substr-helper which i could use to get a part of a string in the panel?

I’m using kirby-builder and would like to use something like in my blueprints:

label: {{title.substr:30}}

Do queries work for labels at all? If they did, it should be

" {{ page.title.excerpt(30) }}"

or something like this.

That doesn’t work in the kirby-builder. Maybe it’s an idea for @timoetting to implement, because often the content of certain fields is to long to put into the label of an builder element. But an excerpt of that content would be fine …

Ah, I totally missed the builder context. Using page doesn’t even make sense, because title is a field in your fieldset and the key is needed to find the correct value, once you use anything else within the braces, the field will no longer be found. This is not Kirby query language used here.

Hey @andio. You are right, this syntax is not possible inside Kirby Builder right now. I am planning a css based fix where the label of builder blocks gets cut off behind ellipsis, when it is too long. Right now, we have an ugly line break when the content of the label is too long.

Would this solve your problem?

This would solve the problem. Thank you for your inspiration.

Here is the possible solution:

.kBuilderBlock__content .kBuilderBlock__label {
    width: calc(100% - 1.75rem);
}

.kBuilderBlock__content .kBuilderBlock__label>span:nth-of-type(2) {
    max-width: 95%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

Only tested in Chrome so far.

Andreas