-2
私はノードJSにhttp://underscorejs.org/との奇妙な行動を見つけたが起こる:ノードJSがフリーズとのReferenceErrorは
我々はテンプレート機能を評価する際に参照エラーが発生し、ノードJSがフリーズします!
例:
例1:HAPPY DAYシナリオ:
var template = "<%= test %>";
var compiledTemplate = _.template(template);
var result = compiledTemplate({test:1});
console.log(result);
//RESULT (both BROWSER and NODE JS):
//1
実施例2:ERRORシナリオ(余分=閉じる前)をコンパイル:
var template = "<%= test =%>";
var compiledTemplate = _.template(template);
var result = compiledTemplate({test:1});
console.log(result);
//RESULT (both BROWSER and NODE JS):
//uncaughtException { [SyntaxError: Unexpected token)]
例3:評価エラーシナリオ(テストが定義されていない):
var template = "<%= test %>";
var compiledTemplate = _.template(template);
var result = compiledTemplate({no_test_defined:1});
console.log(result);
//RESULT (BROWSER):
//Uncaught ReferenceError: test is not defined
//RESULT (NODE JS):
//Node JS FREEZES - nothing happens, neither and error is thrown, neither the flow goes on
誰もこれまで同様の動作をしていましたか?解決策のヒント? try/catchブロックで例外をキャッチする必要があります...
乾杯!私は最終的に問題があったものを見つけることができ、いくつかのトラブルシューティング後
オスカー