Skip to content

Commit ef92a93

Browse files
Merge pull request #548 from teehemkay/dev
Add test cases for @block-partial issue in Handlebars engine
2 parents de89108 + 077fc9e commit ef92a93

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

test/engine_handlebars_tests.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,42 @@ tap.test('hidden handlebars patterns can be called by their nice names', functio
222222
test.equals(util.sanitized(testPattern.render()), util.sanitized('Here\'s the hidden atom: [I\'m the hidden atom\n]\n'));
223223
test.end();
224224
});
225+
226+
tap.test('@partial-block template should render without throwing (@geoffp repo issue #3)', function(test) {
227+
test.plan(1);
228+
229+
var patternPath = path.join('00-atoms', '00-global', '10-at-partial-block.hbs');
230+
231+
// do all the normal processing of the pattern
232+
var patternlab = new fakePatternLab();
233+
var assembler = new pa();
234+
var atPartialBlockPattern = assembler.process_pattern_iterative(patternPath, patternlab);
235+
assembler.process_pattern_recursive(patternPath, patternlab);
236+
237+
var results = '{{> @partial-block }}' + eol + 'It worked!' + eol;
238+
test.equal(atPartialBlockPattern.render(), results);
239+
test.end();
240+
})
241+
242+
tap.test('A template calling a @partial-block template should render correctly', function(test) {
243+
test.plan(1);
244+
245+
// pattern paths
246+
var pattern1Path = path.join('00-atoms', '00-global', '10-at-partial-block.hbs');
247+
var pattern2Path = path.join('00-molecules', '00-global', '10-call-at-partial-block.hbs');
248+
249+
// set up environment
250+
var patternlab = new fakePatternLab(); // environment
251+
var assembler = new pa();
252+
253+
// do all the normal processing of the pattern
254+
assembler.process_pattern_iterative(pattern1Path, patternlab);
255+
var callAtPartialBlockPattern = assembler.process_pattern_iterative(pattern2Path, patternlab);
256+
assembler.process_pattern_recursive(pattern1Path, patternlab);
257+
assembler.process_pattern_recursive(pattern2Path, patternlab);
258+
259+
// test
260+
var results = 'Hello World!' + eol + 'It worked!' + eol;
261+
test.equals(callAtPartialBlockPattern.render(), results);
262+
test.end();
263+
})
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{> @partial-block }}
2+
It worked!
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#> atoms-at-partial-block }}
2+
Hello World!
3+
{{/atoms-at-partial-block}}

0 commit comments

Comments
 (0)