# Feature idea: Parameterized macros (or, "smart replacements")

**URL:** https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098
**Category:** Feature
**Created:** [November 24, 2021, 11:22pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098 "2021-11-24T23:22:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [November 24, 2021, 11:22pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098/1 "2021-11-24T23:22:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 6, 2022, 6:16pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098/2 "2022-01-06T18:16:42Z")

</div>

This is doable as a small theme-component that hooks into the decoratedCooked method as documented at [Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648/1#heading--4-c-12)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 17, 2022, 9:34pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098/3 "2022-01-17T21:34:01Z")

</div>

Not with parameters, but, try

Admin → Customize → Watched Words → Replace

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [January 17, 2022, 10:24pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098/4 "2022-01-17T22:24:54Z")

</div>

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)`.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 17, 2022, 10:26pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098/5 "2022-01-17T22:26:34Z")

</div>

Generally the way that’s handled is through oneboxing, e.g. paste the URL on a line by itself:

`https://matrix.to/#/#home-automtaion:fedoraproject.org`

Understandably that’s kind of an annoying complex URL to paste though.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [January 17, 2022, 10:38pm UTC](https://meta.discourse.org/t/feature-idea-parameterized-macros-or-smart-replacements/210098/6 "2022-01-17T22:38:33Z")

</div>

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.
