The discussion revolves around the idea of implementing parameterized macros or “smart replacements” in Discourse. mattdm proposed the concept, seeking a way to create site-wide or category-wide macros that accept parameters. This would enable users to insert dynamic links, such as {chat:social}, which would automatically update if the macro is ever changed.
The current “watched words” feature does not support this kind of parameterized replacement. codinghorror suggested using the “watched words” feature as a workaround, but mattdm emphasized the need to avoid pre-defining all possible options. Instead, they want to allow users to generate links dynamically, such as {chat:home-automation}.
codinghorror mentioned that oneboxing could be a solution, but mattdm pointed out that the URL is complex and not easily obtainable. Moreover, they want to be able to update the links easily if the domain name or parameters change.
Falco noted that implementing parameterized macros is feasible through a small theme component that hooks into the decoratedCooked method.
Is there a way to make site- (or category-?) wide “macros” which would accept parameters?
For example, links to Fedora’s Matrix chat rooms are in the form https://matrix.to/#/#social:fedoraproject.org. I’d like people to be able to write something like {chat:social}, and have that appear as a link with the “social” parameter inserted in the proper place.
Crucially, if the macro is ever updated, all of the instances across the site should likewise follow. (Although it’s acceptable if that’s “eventually” rather than instant, as I don’t imagine wanting to use this for something that would change frequently.)
I know there’s the “watched words” feature, but I don’t see any way to do this kind of parameterized replacement.
The thing I’d really like to avoid is to have to pre-define all of the possible options — like, if someone makes a new chat room for home-automation, I don’t want someone to have to manually add it… I’d just like {chat:home-automation} to generate [Fedora Chat: #home-automation](https://matrix.to/#/#home-automtaion:fedoraproject.org).
Yeah. And, it’s actually even worse because the URL that actually should be used is https://matrix.to/#/#home-automation:fedoraproject.org?web-instance[element.io]=chat.fedoraproject.org, which Matrix does not currently conveniently provide anywhere.
Plus, I’d like to be able to change it if, for example, the domain name changes, or their wacky parameters change, without going back and updating all of the links.