Jérôme Jérôme - 2 months ago 8x
CoffeeScript Question

Unmatched outdent in coffeescript code

I have made this coffeescript piece of code but I get an error during the compilation

error: unmatched OUTDENT near 'callback newResults'

match: /\B:([\-+\w]*)$/,
search: (term, callback) ->
results = []
results2 = []
results3 = []

$.each(emojiStrategy, (shortname, data) ->
if shortname.indexOf(term) > -1
if data.aliases isnt null && data.aliases.indexOf(term) > -1
else if data.keywords isnt null && data.keywords.indexOf(term) > -1

if term.length >= 3
results.sort((a, b) ->
return (a.length > b.length))
results2.sort((a, b) ->
return (a.length > b.length))

newResults = results.concat(results2).concat(results3)
callback newResults

template: (shortname) ->
return '<img class="emojione" src="//cdn.jsdelivr.net/emojione/assets/png/' + emojiStrategy[shortname].unicode + '.png"> :' + shortname + ':'

replace: (shortname) ->
return ':' + shortname + ': '

index: 1,
maxCount: 10
}], {
footer: '<a href="http://www.emoji.codes" target="_blank">Browse All<span class="arrow">ยป</span></a>'

I understand the error but I don't see any problem in the syntax/indent.

My first though was there is no comma after the
function, but the code is good when I delete all
function content.

This is what I'm trying to do in coffeescript

match: /\B:([\-+\w]*)$/,
search: function(term, callback){},
template: function (shortname) {},
replace: function (shortname) {},
index: 1,
maxCount: 10

Thanks for your help


You have an opening parenthesis on this line:

$.each(emojiStrategy, (shortname, data) ->

But there is no matching closing parenthesis. The unmatched outdent error is displayed at the last possible line where you could close it before it causes a syntax error. Either omit the opening parenthesis or close it at the right location.