Skip to content

Commit

Permalink
Add 2 replacers
Browse files Browse the repository at this point in the history
for the placeholders question and reponse
see discourse-placeholder-forms-theme-component
  • Loading branch information
bdecotte committed Jul 22, 2021
1 parent 5659a23 commit 68cd32a
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -98,6 +98,7 @@ function openComposerWithTemplateAndAction(controller, post, wrap) {
}

const dataset = wrap.dataset;
const postIdentifier = `d-placeholder-${post.get('topic').id}-${post.id}-`;

return ajax(`/posts/${post.id}`, {
cache: false
Expand All @@ -111,6 +112,20 @@ function openComposerWithTemplateAndAction(controller, post, wrap) {
const match = regex.exec(data.raw || "");

const replacers = [
{
regex: /(\=question=)/g,
fn: () => {
const placeholderIdentifier = `${postIdentifier}question`;
return $.cookie(placeholderIdentifier) || placeholderIdentifier;
}
},
{
regex: /(\=reponse=)/g,
fn: () => {
const placeholderIdentifier = `${postIdentifier}reponse`;
return $.cookie(placeholderIdentifier) || placeholderIdentifier;
}
},
{
regex: /(\$tomorrow)/g,
fn: () => {
Expand Down

0 comments on commit 68cd32a

Please sign in to comment.