From 179c47e4e960a72ee49558f9cbe196b1a4cb4a91 Mon Sep 17 00:00:00 2001
From: Richard Ragan <rragan@ebay.com>
Date: Sun, 11 Aug 2013 10:39:20 -0700
Subject: [PATCH 1/2] Fix Issue #322. block name includes prev text by mistake

---
 lib/dust.js                         |  5 ++++-
 test/jasmine-test/spec/coreTests.js | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/dust.js b/lib/dust.js
index 8a0a3072..5ab48646 100755
--- a/lib/dust.js
+++ b/lib/dust.js
@@ -211,9 +211,12 @@ Context.prototype.current = function() {
 };
 
 Context.prototype.getBlock = function(key, chk, ctx) {
+  var saveData;
   if (typeof key === "function") {
+    saveData = chk.data;
+    chk.data = [];
     key = key(chk, ctx).data.join("");
-    chk.data = []; //ie7 perf
+    chk.data = saveData;
   }
 
   var blocks = this.blocks;
diff --git a/test/jasmine-test/spec/coreTests.js b/test/jasmine-test/spec/coreTests.js
index 306f7ba8..927117fb 100755
--- a/test/jasmine-test/spec/coreTests.js
+++ b/test/jasmine-test/spec/coreTests.js
@@ -189,6 +189,23 @@ var coreTests = [
         expected: "Start\nChild Title\nChild Content\nEnd",
         message: "should test child template"
       },
+      {
+        name:     "issue322",
+        source:   'hi{+"{name}"/}',
+        context:  {},
+        expected: "hi", 
+        message: "should setup base template for next test. hi should not be part of base block name"
+
+      },
+      {
+        name:     "issue322 use base template picks up prefix chunk data",
+        source:   '{>issue322 name="abc"/}' +
+		   "{<abc}ABC{/abc}",
+        context:  {},
+        expected: "hiABC",
+        message: "should use base template and honor name passed in"
+
+      },
       {
         name:     "recursion",
         source:   "{name}{~n}{#kids}{>recursion:./}{/kids}",

From c2e9fd1795eb5d01b5a2dee9cb06bb99d3293b28 Mon Sep 17 00:00:00 2001
From: rragan <rragan@ebay.com>
Date: Thu, 29 Aug 2013 15:01:35 -0700
Subject: [PATCH 2/2] Improve code for issue #322.

---
 lib/dust.js | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/dust.js b/lib/dust.js
index 5ab48646..02793c80 100755
--- a/lib/dust.js
+++ b/lib/dust.js
@@ -211,12 +211,9 @@ Context.prototype.current = function() {
 };
 
 Context.prototype.getBlock = function(key, chk, ctx) {
-  var saveData;
   if (typeof key === "function") {
-    saveData = chk.data;
-    chk.data = [];
-    key = key(chk, ctx).data.join("");
-    chk.data = saveData;
+    var tempChk = new Chunk();
+    key = key(tempChk, this).data.join("");
   }
 
   var blocks = this.blocks;