mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 01:43:45 +08:00
1eec8c3fa6
This adds support for Watched Words to allow replacement with HTML content rather than always replacing with text. Can be useful when automatically replacing with the '<abbr>' tag for example. Discussion - https://meta.discourse.org/t/replace-text-with-more-than-just-links/305672
29 lines
579 B
Ruby
29 lines
579 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:word,
|
|
:regexp,
|
|
:replacement,
|
|
:action,
|
|
:case_sensitive,
|
|
:watched_word_group_id,
|
|
:html
|
|
|
|
def regexp
|
|
WordWatcher.word_to_regexp(word, engine: :js)
|
|
end
|
|
|
|
def action
|
|
WatchedWord.actions[object.action]
|
|
end
|
|
|
|
def include_replacement?
|
|
WatchedWord.has_replacement?(action)
|
|
end
|
|
|
|
def include_html?
|
|
object.action == WatchedWord.actions[:replace] && object.html
|
|
end
|
|
end
|