Skip to content

Add extra characters around a standard merge #15

@gMagicScott

Description

@gMagicScott

From the Facebook group:

How do I pluralize this? [as what="firstname" default="Your"] where I want (Chad's) or (Your). Would this work? [as what="firstname" "'s" default="Your"]

At first, I thought it might be possible to combine two shortcodes like this: [as what="firstname" default="Your" /][block field="Name"]'s[/block], but block checks against a specific value, not a generic "is set".

We could add another attribute to add the extra content when the merge is there.

as

  • what= The field
  • default= display this when field is empty
  • append= add this to the end when variable is set
  • prepend= add this to the beginning when variable is set
[as prepend="Hi " what="firstname" append="!" default="Hello friend," /]

Output when Name not set:
Hello friend,

Output when Name is set (Chad):
Hi Chad!

The ability to prepend wasn't asked for, but I think prepend and append go well together.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions