Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ ID
fragment
ID_START
:
[a-zA-ZА-Яа-я_$@:\u0001-\u0009\u000b-\u001E\u00C0-\u00FF]
[a-zA-ZА-Яа-я_$@:\u0001-\u0008\u000B\u000C\u000E-\u001E\u00C0-\u00FF]
;

fragment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.github.jknack.handlebars.internal;

import static org.junit.Assert.assertEquals;

import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ParseTree;
import org.junit.Assert;
import org.junit.Test;

public class HbsParserTest {
Expand Down Expand Up @@ -118,6 +121,21 @@ public void setDelim() {
parse("{{=+-+ +-+=}}+-+test+-+");
}

@Test
public void whiteSpaceHandledEqually() {
String withSpace = "{{helper param1=\"1\" param2=2}}";
ParseTree tree = parse(withSpace);

String withNewlines = "{{helper\nparam1=\"1\"\nparam2=2}}";
assertEquals("Newlines should be treated the same as spaces", tree.getText(), parse(withNewlines).getText());

String withDosNewlines = "{{helper\r\nparam1=\"1\"\r\nparam2=2}}";
assertEquals("DOS-style newlines should be treated the same as spaces", tree.getText(), parse(withDosNewlines).getText());

String alignedWithTabs = "{{helper\n\tparam1=\"1\"\n\tparam2=2}}";
assertEquals("Tab-aligned variables should be treated the same as spaces", tree.getText(), parse(alignedWithTabs).getText());
}

private ParseTree parse(final String input) {
return parse(input, "{{", "}}");
}
Expand Down