What's the meaning of this line of CoffeeScript? -


i reading through journo's source code , stumbled upon line of code:

markdown  = _.template(source.tostring()) variables 

what variables doing here? _.template(source.tostring()) variables valid stntax @ all?

here's function wrapping line of code:

journo.render = (post, source) ->       catcherrors ->         loadlayout         source or= fs.readfilesync postpath post         variables = rendervariables post         markdown  = _.template(source.tostring()) variables         title     = detecttitle markdown         content   = marked.parser marked.lexer markdown         shared.layout _.extend variables, {title, content} 

yes, valid. parenthesis optional (sometimes) in coffeescript when invoking function, taking result of template , invoking arguments. compiles javascript:

_.template(source.tostring())(variables); 

from coffeescript documentation:

you don't need use parentheses invoke function if you're passing arguments. implicit call wraps forward end of line or block expression.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -