Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(framework): remove white spaces from hbs parser #1613

Merged
merged 1 commit into from
May 14, 2020
Merged

Conversation

fifoosid
Copy link
Contributor

Fixes #1600

@@ -5,7 +5,7 @@ const includesReplacer = require("./includesReplacer");
const svgProcessor = require("./svgProcessor");

const removeWhiteSpaces = (source) => {
return source.replace(/\n+/g, "").replace(/\s+</g, "<").replace(/}}\s+{{/g, "}}{{");
return source.replace(/\n+/g, "").replace(/\s+</g, "<").replace(/}}\s+{{/g, "}}{{").replace(/\t+/g, " ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to move your new RegExp immediately after the one stripping new lines. This way, the spaces it adds can be stripped by the next regular expressions.
In addition, the regular expression that strips whitespaces around < only strip to the left, not to the right.
Furthermore, there is no equivalent RegExp that strips spaces around > so there is always a space at the end of each line.

I tested with:

return source
		.replace(/\n+/g, "")
		.replace(/\t+/g, " ")
		.replace(/\s*<\s*/g, "<")
		.replace(/\s*>\s*/g, ">")
		.replace(/}}\s+{{/g, "}}{{");

which moves yours to the second line, adds one for > and strips spaces on both sides for both < and >.

@fifoosid fifoosid merged commit ec5a9cf into master May 14, 2020
@fifoosid fifoosid deleted the hbs-compiler branch May 15, 2020 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HBS parser does not strip whitespace
2 participants