From 7e4548979fab92e5e0a7726cbe4dc4d7d905d1e6 Mon Sep 17 00:00:00 2001 From: Sahab Yazdani Date: Tue, 12 Oct 2010 19:55:36 -0700 Subject: [PATCH] Comments should have a ! before the closing tag. The comment syntax is now {{! TEXT !}} --- mustache.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mustache.js b/mustache.js index 109d01c..ca5b589 100644 --- a/mustache.js +++ b/mustache.js @@ -459,13 +459,21 @@ var Mustache = function() { }, discard: function(parserContext, contextStack) { - if (parserContext.token()===parserContext.closeTag) { - return 'text'; + if (parserContext.token()==='!') { + return 'closeComment'; } else { return 'discard'; } }, + closeComment: function(parserContext, contextStack) { + if (parserContext.token()!==parserContext.closeTag) { + return 'discard'; + } else { + return 'text'; + } + }, + endOfDoc: function(parserContext, contextStack) { // eventually we may want to give better error messages throw new ParserException('Unexpected end of document.');