# 텍스트를 교체하고 동적으로 업데이트하는 방법

**URL:** <https://meta.discourse.org/t/how-to-replace-text-and-update-dynamically/244317>\
**Category:** Support\
**Created:** [11월 4, 2022, 6:45오전 UTC](https://meta.discourse.org/t/how-to-replace-text-and-update-dynamically/244317 "2022-11-04T06:45:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)\
**Post date:** [11월 4, 2022, 6:45오전 UTC](https://meta.discourse.org/t/how-to-replace-text-and-update-dynamically/244317/1 "2022-11-04T06:45:02Z")

</div>

특정 게시물(약 100개이며 계속 증가 중)에 면책 조항이나 고지 내용을 추가해야 합니다. 고지 내용은 향후 변경될 수 있으므로, 100개의 게시물 각각에 [DISCLOSURE-GOES-HERE]를 추가하고 싶습니다. 수동으로 추가하는 것은 문제없습니다. 하지만 향후 고지 내용을 업데이트할 때, 단 한 곳만 수정하고 싶습니다.

**시도해 본 방법:**

1. Watched Words. 기존 게시물은 게시물을 편집하기 전까지는 업데이트된 고지 내용이 표시되지 않는다는 문제가 있습니다. 이 용도에는 목적이 무색해집니다.

2. 요소의 innerHTML을 대체하는 Javascript. 제가 잘못한 것 같습니다. 자식 노드 대체와 관련된 오류가 발생했습니다:

```plaintext
<script type="text/discourse-plugin" version="0.8">
    var disclosures = "• Important Disclosures: We are not responsible, etc, etc."
    api.decorateCooked($elem => {
        var el = $elem[0];
        el.innerHTML = el.innerHTML.replace('[DISCLOSURE-GOES-HERE]', disclosures);
    });
</script>

```

1. Auto-linkify 테마 컴포넌트. 다른 용도에는 유용하지만, 저는 고지 링크가 아니라 고지 텍스트를 표시하고 싶습니다.

2. rails 콘솔에서 텍스트를 교체할 수 있다는 것은 알고 있지만, 관리자가 이를 유지 관리하길 원합니다.

---

_[View the full topic](https://meta.discourse.org/t/how-to-replace-text-and-update-dynamically/244317)._
