Skip to content

Commit

Permalink
Fix issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmorand committed Nov 3, 2017
1 parent be82d07 commit 852b372
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Depper extends Transform {

break;
}
case 'Twig.logic.type.if':
case 'Twig.logic.type.for':
case 'Twig.logic.type.macro':
case 'Twig.logic.type.setcapture': {
Expand Down
24 changes: 23 additions & 1 deletion test/depper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const path = require('path');

tap.test('depper', function (test) {
test.plan(11);
test.plan(12);

test.test('should handle Twig.logic.type.include', function (test) {
let d = new Depper();
Expand Down Expand Up @@ -259,4 +259,26 @@ tap.test('depper', function (test) {

d.end(entry);
});

test.test('should handle Twig.logic.type.if', function (test) {
let d = new Depper();
let entry = path.join(__dirname, '/fixtures/if/entry.twig');

let rows = [];

d.on('data', function (row) {
rows.push(row);
});

d.on('finish', function () {
test.same(rows.sort(), [
path.join(__dirname, '/fixtures/if/entry.twig'),
path.join(__dirname, '/fixtures/if/partial.twig')
].sort());

test.end();
});

d.end(entry);
});
});
3 changes: 3 additions & 0 deletions test/fixtures/if/entry.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% if foo %}
{% include './partial.twig' %}
{% endif %}
3 changes: 3 additions & 0 deletions test/fixtures/if/partial.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
Partial
</div>

0 comments on commit 852b372

Please sign in to comment.