# 게시물에 변수/BBCODE를 사용하는 방법?

**URL:** https://meta.discourse.org/t/how-to-use-variables-bbcode-in-a-post/194226
**Category:** Development
**Created:** [6월 17, 2021, 7:01오후 UTC](https://meta.discourse.org/t/how-to-use-variables-bbcode-in-a-post/194226 "2021-06-17T19:01:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [6월 17, 2021, 7:01오후 UTC](https://meta.discourse.org/t/how-to-use-variables-bbcode-in-a-post/194226/1 "2021-06-17T19:01:56Z")

</div>

게시글에 이런 내용을 어떻게 작성하는 것이 가장 좋을지 고민 중입니다:

```plaintext
[Click here to save your spot](https://mysite.com/$CURRENT_USERNAME)

```

여기서 `$CURRENT_USERNAME`은 로그인한 사용자에 따라 다른 값으로 바뀌어야 합니다.

테마 컴포넌트 내에서 플러그인 API를 사용하여 현재 사용자 이름을 가져올 수 있다고 생각하지만, 실제로 링크를 삽입하는 가장 좋은 방법에 대해서는 확신이 서지 않습니다.

한 가지 선택지는 [discourse-details](https://github.com/discourse/discourse/tree/master/plugins/discourse-details)나 [discourse-spoiler-alert](https://github.com/discourse/discourse-spoiler-alert)처럼 새로운 bbcode 명령어를 추가하는 플러그인을 작성하는 것입니다. 예를 들어 다음과 같이요:

```plaintext
[dynamic-url description="Click here to save your spot" pattern="https://mysite.com/$CURRENT_USERNAME"][/dynamic-url]

```

또는 더 일반적인 형태로:

```plaintext
[dynamic-tag tagName="iframe" src="https://mysite.com/$CURRENT_USERNAME"][/dynamic-tag]

```

하지만 더 간단한 대안이 있는지 궁금합니다.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [6월 21, 2021, 12:58오후 UTC](https://meta.discourse.org/t/how-to-use-variables-bbcode-in-a-post/194226/2 "2021-06-21T12:58:33Z")

</div>

플레이스홀더 테마 컴포넌트를 확인해 보셨나요?

> [@Placeholder Forms](https://meta.discourse.org/t/discourse-placeholder-forms-theme-component/113533):
>
> discourse2Summary Placeholder Forms will let you build dynamic documentation, by creating a form that replaces any occurrence of a =PATTERN= in your post with the value from a text or selectable input field.eyeglassesPreview [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/placeholder-forms)hammer_and_wrenchRepository Link [https://github.com/discourse/discourse-placeholder-theme-component](https://github.com/discourse/discourse-placeholder-theme-component)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component …

제안하신 것보다 훨씬 간단한 버전입니다. 그렇지 않으면 마크다운 엔진에 접근하여 치환을 처리해야 하지만, 클라이언트와 서버 측에서 치환에 필요한 정보에 엔진이 접근할 수 있도록 해야 합니다. 그 부분이 까다롭습니다.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [6월 21, 2021, 1:01오후 UTC](https://meta.discourse.org/t/how-to-use-variables-bbcode-in-a-post/194226/3 "2021-06-21T13:01:20Z")

</div>

대안으로, 플러그인보다 가볍게 동작하는 테마 컴포넌트를 작성하고 wrap을 사용하는 방법도 있습니다:

> [@Generic bbcode wrapper for theme components](https://meta.discourse.org/t/generic-bbcode-wrapper-for-theme-components/123516):
>
> I added this feature a while back and realised I didn’t post about it. You can now use a special syntax in markdown to have it cooked and usable in theme components without having to write a plugin. // wrapped in div.d-wrap [wrap=baz foo=bar]Content[/wrap] // wrapped in div.d-wrap [wrap=baz foo=bar] Content [/wrap] // wrapped in div.d-wrap [wrap=baz foo=bar] [/wrap] // this one will be rendered as a span.d-wrap instead of a div.d-wrap a [wrap=baz]Content[/wrap] b The name of the component w…
