Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Add support for more whitespace positions within expressions - #327

Closed
cipriancraciun wants to merge 3 commits into
askama-rs:masterfrom
cipriancraciun:patches/upstream/allow-spaces
Closed

Add support for more whitespace positions within expressions#327
cipriancraciun wants to merge 3 commits into
askama-rs:masterfrom
cipriancraciun:patches/upstream/allow-spaces

Conversation

@cipriancraciun

Copy link
Copy Markdown
Contributor

As reported in #315 at the moment whitespaces aren't allowed in many places where normal Rust would allow them.

This pull request adds support for whitespaces in:

  • in function calls: x ( 1 , 2 );
  • in path elements: module :: element;
  • in attributes: x . y . z;
  • in filter arguments: x| filter ( 1 , 2 );
  • before unary operators: ! false and - 42;
  • also allow more than a single whitespace;

Also change some tests to include whitespaces in various positions.

As noted in #315 at the moment there is a language ambiguity regarding bitwise or and filter application. As such at the moment the pipe character | should not be preceded by a space when wanting filter application, and must always be preceded when wanting bitwise or. (This is not a deficiency of the current patch.)

@djc

djc commented May 25, 2020

Copy link
Copy Markdown
Collaborator

Similar to #323, I'm okay with the code generator changes but let's only have a specific test that tests some subset of the code generator for whitespace sensitivity.

* in function calls: `x ( 1 , 2 )`;
* in path elements: `module :: element`;
* in attributes: `x . y . z`;
* in filter arguments: `x| filter ( 1 , 2 )`;
* before unary operators: `! false` and `- 42`;
* in grouped expressions: `( 1 + 2 )`;
* also allow more than a single whitespace;

Change some tests to include whitespaces in various positions.
@cipriancraciun
cipriancraciun force-pushed the patches/upstream/allow-spaces branch 2 times, most recently from 6021e9c to 643bf3a Compare May 25, 2020 13:38
@cipriancraciun
cipriancraciun force-pushed the patches/upstream/allow-spaces branch from 643bf3a to bafe8a0 Compare May 25, 2020 14:31
@djc

djc commented Jun 30, 2020

Copy link
Copy Markdown
Collaborator

Merged as e71e680 and af2fd0b. Thanks!

@djc djc closed this Jun 30, 2020
@cipriancraciun
cipriancraciun deleted the patches/upstream/allow-spaces branch June 30, 2020 13:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants