From abfaddeb3188fcd111827c3db93b01f7afce6447 Mon Sep 17 00:00:00 2001 From: Guilherme I F L Weizenmann Date: Thu, 22 Sep 2016 17:04:44 -0300 Subject: [PATCH 1/2] Add @value to context when iterating over maps Add @value to context to more semantic the access to map key/value pairs --- .../java/com/github/jknack/handlebars/helper/EachHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java b/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java index 3ec3f54c0..9336215ff 100644 --- a/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java +++ b/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java @@ -90,6 +90,7 @@ public Object apply(final Object context, final Options options) Object value = entry.getValue(); Context itCtx = Context.newBuilder(parent, value) .combine("@key", key) + .combine("@value", value) .combine("@first", first ? "first" : "") .combine("@last", !loop.hasNext() ? "last" : "") .build(); From c42c36ef1d47094af443a7e9cbbcd24501b5334a Mon Sep 17 00:00:00 2001 From: Guilherme I F L Weizenmann Date: Thu, 22 Sep 2016 22:07:49 -0300 Subject: [PATCH 2/2] Add @value syntax to Iterable --- .../java/com/github/jknack/handlebars/helper/EachHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java b/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java index 9336215ff..4d4fa1512 100644 --- a/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java +++ b/handlebars/src/main/java/com/github/jknack/handlebars/helper/EachHelper.java @@ -63,6 +63,7 @@ public Object apply(final Object context, final Options options) Object it = loop.next(); Context itCtx = Context.newContext(parent, it); itCtx.combine("@index", index) + .combine("@value", it) .combine("@first", index == base ? "first" : "") .combine("@last", !loop.hasNext() ? "last" : "") .combine("@odd", even ? "" : "odd")