From 5c3a93e07928339dcf1ee9d69bdaa13ef44f88c9 Mon Sep 17 00:00:00 2001 From: robbytx Date: Wed, 12 Mar 2014 13:00:27 -0500 Subject: [PATCH] Correct number of braces for error message --- src/main/java/com/samskivert/mustache/Mustache.java | 2 +- src/test/java/com/samskivert/mustache/MustacheTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/samskivert/mustache/Mustache.java b/src/main/java/com/samskivert/mustache/Mustache.java index 1145ea1..13b9b27 100644 --- a/src/main/java/com/samskivert/mustache/Mustache.java +++ b/src/main/java/com/samskivert/mustache/Mustache.java @@ -457,7 +457,7 @@ public class Mustache int end3 = (char)source.read(); if (end3 != '}') { throw new MustacheParseException( - "Invalid triple-mustache tag: {{{" + text + "}}", line); + "Invalid triple-mustache tag: {{{" + text.substring(1) + "}}", line); } } catch (IOException e) { throw new MustacheException(e); diff --git a/src/test/java/com/samskivert/mustache/MustacheTest.java b/src/test/java/com/samskivert/mustache/MustacheTest.java index 9f50e35..e60adcc 100644 --- a/src/test/java/com/samskivert/mustache/MustacheTest.java +++ b/src/test/java/com/samskivert/mustache/MustacheTest.java @@ -583,6 +583,15 @@ public class MustacheTest }); } + @Test public void testInvalidTripleMustache () { + try { + Mustache.compiler().compile("{{{foo}}"); + fail("Expected MustacheParseException"); + } catch (MustacheParseException e) { + assertEquals("Invalid triple-mustache tag: {{{foo}} @ line 1", e.getMessage()); + } + } + @Test public void testNullValueGetsNullDefault () { test(Mustache.compiler().nullValue("foo"), "foobar", "{{nullvar}}{{nonnullvar}}", new Object() {