0
我正在編寫NodeJS應用程序,該應用程序使用Handlebars爲一些已編譯的HTML提供服務。Handlebars nodejs獲取錯誤
express = require 'express'
handlebars = require 'handlebars'
fs = require 'fs'
express().get '/foo.html', ->
fooData = {isFoo:true}
template = handlebars.compile fs.readFileSync('foo-template.html').toString()
htmlString = template(data)
res.send htmlString
但是,我的foo.html文件有一些錯誤。
<html>
{{#if isFoo}}
What's up foo
<!-- closing {{/if}} tag is missing -->
</html>
當我訪問「/foo.html」,服務器似乎很好地工作,但我的要求只是掛起。有些事情一定是出了問題。 爲什麼不是Handlebars拋出某種異常?
或者,我如何確保Handlebars在我編寫foo.html時拋出異常?