Skip to content

Commit 664a516

Browse files
committed
fix root node templating around whitespace
1 parent 86b1c97 commit 664a516

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ var failOnBadTokens = function(tokens) {
227227

228228

229229
var pullRoot = function(tokens) {
230-
var template = R.repeatN('#', tokens.length || 0).join('');
230+
var template = '';
231231
if (lex.check(tokens[0], {token: 'space'})) {
232232
template = tokens.shift().repr + template;
233233
}
234+
template += R.repeatN('#', tokens.length || 0).join('');
234235
return astNode('expr', tokens, {template: template});
235236
};
236237

test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ describe('Parser', function() {
323323

324324
describe('Echo compiler', function() {
325325
describe('on simple minimal-node ASTs', function() {
326+
it('should work on just whitespace', function() {
327+
assert.equal(compileE(' '), ' ');
328+
});
326329
it('should work for literals', function() {
327330
assert.equal(compileE('1'), '1');
328331
});

0 commit comments

Comments
 (0)