# 输出主题设置而不剥离html

**URL:** https://meta.discourse.org/t/outputting-a-theme-setting-without-stripping-the-html/260751
**Category:** Development
**Created:** [2023年四月6日 03:56 UTC](https://meta.discourse.org/t/outputting-a-theme-setting-without-stripping-the-html/260751 "2023-04-06T03:56:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Magnetidog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/magnetidog/32/116910_2.png) [@Magnetidog](https://meta.discourse.org/u/Magnetidog)
#### Post date: [2023年四月6日 03:56 UTC](https://meta.discourse.org/t/outputting-a-theme-setting-without-stripping-the-html/260751/1 "2023-04-06T03:56:40Z")

</div>

大家好，

我正在尝试输出主题中的一个主题设置，该设置包含一些 HTML。无论如何，以下内容不起作用：

```plaintext
{{html-safe (theme-setting "my_text")}}

```

我哪里做错了？

谢谢。

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2023年四月6日 12:25 UTC](https://meta.discourse.org/t/outputting-a-theme-setting-without-stripping-the-html/260751/2 "2023-04-06T12:25:47Z")

</div>

你好 👋  
我做了一个主题组件，它能正常工作。

`settings.yml` 的摘录：

```yaml
content_before:
  default: "<strong>捐赠进度条</strong>"
  type: string
content_after:
  default: "<em>一旦达到捐赠目标，进度条就会消失。</em>"
  type: string

```

`head_tag.html` 的摘录：

```handlebars
<div class="progress-bar-before">{{html-safe (theme-setting "content_before")}}</div>
    <div class="progress-bar-data">
        <div class="progress-bar-container">
            <div class="progress-bar"></div>
        </div>
        <div class="progress-status"></div>
    </div>
<div class="progress-bar-before">{{html-safe (theme-setting "content_after")}}</div>

```

结果：

![image](https://global.discourse-cdn.com/meta/original/4X/4/1/8/41869ea955da5a17a7d85992b25439b3756aeda0.png)

也许你能从中找到一些线索？

或者你能分享更多你的主题组件代码吗？

---

<div class="post-metadata">

### Author: ![Magnetidog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/magnetidog/32/116910_2.png) [@Magnetidog](https://meta.discourse.org/u/Magnetidog)
#### Post date: [2023年四月6日 15:47 UTC](https://meta.discourse.org/t/outputting-a-theme-setting-without-stripping-the-html/260751/3 "2023-04-06T15:47:37Z")

</div>

非常感谢！我会努力找出我哪里做错了！
