Skip to content

Commit

Permalink
Merge pull request #870 from antoineveldhoven/multiple-spaces-elseif
Browse files Browse the repository at this point in the history
Allow multiple spaces after elseif statement.
  • Loading branch information
willrowe authored Oct 11, 2023
2 parents 59d991d + fe206cc commit caced6b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/twig.logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = function (Twig) {
* Format: {% elseif expression %}
*/
type: Twig.logic.type.elseif,
regex: /^elseif\s?([^\s].*)$/,
regex: /^elseif\s*([^\s].*)$/,
next: [
Twig.logic.type.else_,
Twig.logic.type.elseif,
Expand Down
1 change: 1 addition & 0 deletions test/test.logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Twig.js Logic ->', function () {

describe('elseif ->', function () {
it('should ignore spaces', function () {
twig({data: '{% if (1 == 2) %}false{% elseif (1 == 1) %}true{% endif %}'}).render().should.equal('true');
twig({data: '{% if (1 == 2) %}false{% elseif (1 == 1) %}true{% endif %}'}).render().should.equal('true');
twig({data: '{% if (1 == 2) %}false{% elseif(1 == 1) %}true{% endif %}'}).render().should.equal('true');
});
Expand Down

0 comments on commit caced6b

Please sign in to comment.