mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 16:29:32 +08:00
FIX: [quote] without params was failing.
This commit is contained in:
@ -6,9 +6,13 @@ Discourse.Dialect.replaceBlock({
|
||||
stop: '[/quote]',
|
||||
emitter: function(blockContents, matches, options) {
|
||||
|
||||
var params = {'class': 'quote'},
|
||||
username;
|
||||
|
||||
if (matches[1]) {
|
||||
var paramsString = matches[1].replace(/\"/g, ''),
|
||||
params = {'class': 'quote'},
|
||||
paramsSplit = paramsString.split(/\, */),
|
||||
paramsSplit = paramsString.split(/\, */);
|
||||
|
||||
username = paramsSplit[0];
|
||||
|
||||
paramsSplit.forEach(function(p,i) {
|
||||
@ -19,6 +23,7 @@ Discourse.Dialect.replaceBlock({
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var avatarImg;
|
||||
if (options.lookupAvatarByPostNumber) {
|
||||
@ -41,11 +46,15 @@ Discourse.Dialect.replaceBlock({
|
||||
});
|
||||
}
|
||||
|
||||
if (!username) {
|
||||
return ['p', ['aside', params, contents ]];
|
||||
}
|
||||
|
||||
return ['p', ['aside', params,
|
||||
['div', {'class': 'title'},
|
||||
['div', {'class': 'quote-controls'}],
|
||||
avatarImg ? ['__RAW', avatarImg] : "",
|
||||
I18n.t('user.said', {username: username})
|
||||
username ? I18n.t('user.said', {username: username}) : ""
|
||||
],
|
||||
contents
|
||||
]];
|
||||
|
@ -74,6 +74,11 @@ test("quotes", function() {
|
||||
formatQuote("this is <not> a bug",
|
||||
"[quote=\"eviltrout, post:1, topic:2\"]\nthis is <not> a bug\n[/quote]\n\n",
|
||||
"it escapes the contents of the quote");
|
||||
|
||||
format("[quote]test[/quote]",
|
||||
"<aside class=\"quote\"><blockquote><p>test</p></blockquote></aside>",
|
||||
"it supports quotes without params");
|
||||
|
||||
});
|
||||
|
||||
test("quote formatting", function() {
|
||||
|
Reference in New Issue
Block a user