Skip to content

Handlebars helpers: Replace text #194

Description

@Gremious

It would be very nice if there was a "search and replace" helper in handlebars.

Use case:

I have a card with a desc field like so:

"Deal [6] damage."

I would like to write something like in the following:

.font_dice { font-family: 'DicierRL'; } // a font with dice symbols only
.font_regular { font-family: 'Overpass'; }
<div class="desc font_regular">
        // replace, field, text_to_find, text_to_replace_with
        {{replace card.desc "[6]" <span class="font_dice">6</span>}}
</div>

So that the output is like so:

<div class="desc font_regular">
      Deal <span class="font_dice">6</span> damage.
</div>

Resulting in the following render:

Image

This way I don't have to write cumbersome html tags in my card descriptions and instead can just quickly write "[6]" when I want a d6 icon.

Would be even more phenomenal if it supported regex so that I could write capture groups and re-use them in the replaced output. This way I could write "[any digit]" and still have it work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions