텍스트 및 시스템 이메일 템플릿 커스터마이징을 위한 보간 키

:bookmark: 이 가이드는 Discourse에서 텍스트 및 시스템 이메일 템플릿을 커스터마이징하는 데 사용되는 보간 키(interpolation keys)에 대한 자세한 개요를 제공합니다.

:person_raising_hand: 필요한 사용자 권한: 관리자

Discourse에서 텍스트 커스터마이징 또는 특정 이메일 템플릿 커스터마이징을 할 때 일부 템플릿에 사용할 수 있는 플레이스홀더 변수가 있다는 것을 눈치채셨을 수 있습니다.

Discourse에서는 이러한 변수를 *보간 키(Interpolation Keys)*라고 부릅니다.

보간 키 이해하기

보간 키는 특정 Discourse 템플릿에서 사용할 수 있는 플레이스홀더입니다. 이를 통해 텍스트 및 이메일 템플릿에 동적 콘텐츠를 삽입할 수 있습니다.

Account Created 이메일 템플릿의 보간 키 예시:

%{username} 또는 %{site_name}과 같은 이러한 키는 이메일이 전송될 때 실제 데이터로 대체됩니다.

일반적으로 이러한 플레이스홀더는 속한 템플릿 내에서 위치를 변경할 수 있지만, 서버 코드와 연결되어 해당 템플릿에 종속되어 있기 때문에 해당 템플릿에서만 사용 가능하며 다른 템플릿으로 이동할 수 없습니다.

그러나 일부 템플릿 그룹은 기본 템플릿에 이미 존재하는 키 외에도 추가 보간 키를 허용합니다.

추가 보간 키

사용자 환영 시스템 메시지

system_messages.welcome_user 템플릿의 경우, 다음 추가 키를 사용할 수 있습니다:

  • username: 사용자의 사용자 이름
  • name: 사용자의 전체 이름
  • name_or_username: 사용자의 전체 이름 또는 사용자 이름

이러한 값은 런타임에서 SystemMessage 클래스에 의해 제공됩니다 (관련 Discourse 코드는 system_message.rb를 참조하세요).

사용자 알림 이메일

user_notifications 및 관련 이메일 템플릿(unsubscribe_mailing_listunsubscribe_link 포함)의 경우, topic_title, username, site_name, url, unsubscribe_url 등을 포함한 많은 추가 키를 사용할 수 있습니다.

허용되는 모든 사용자 정의 보간 키의 완전하고 최신 목록 및 해당 키가 적용되는 템플릿 그룹에 대해서는 translation_override.rb의 Discourse 소스 코드ALLOWED_CUSTOM_INTERPOLATION_KEYS를 참조하세요.

9개의 좋아요

That’s not correct. Currently that works only for system_messages.welcome_user, but we could extend it to all other keys. This is pr-welcome material.

4개의 좋아요

Thanks for pointing that out, this has been updated in the guide.

2개의 좋아요

Hi!

How can I modify the value for some of these interpolation keys? For instance, %{search_answer}

Thanks!

Hi!
It says that this key is not valid:

P.S.
I’m replacing in text not email (does it make a difference)? Thanks!

I don’t think those are global and free to use everywhere.

1개의 좋아요

Thanks @Jagster ! I’m using them in the text customization so based on the topic post, it’s supposed to work?

Topic is actually about email templates and those texts. So, you can’t use interpolations keys outside right context. That’ts why we have other keys for emails, other for some AI prompts etc.

Sure, plugins can do a lot of things, but this time not out of the box.

And disclaimer: I’m just another end user and I can be horrible wrong too. But I’m quite sure I’m right — and that’s why your try doesn’t work :man_shrugging:

Okay, thank you so much for your support. It looks like it’s not working even in used in an email template:

My bet is you can use %{username} in ”User did…” templates, and all other templates don’t support it.

But we’ll see tomorrow when all gurus are waken.