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

[FEATURE] Improve inline syntax for arguments and passing #399

Merged

Conversation

NamelessCoder
Copy link
Member

This patch improves the inline syntax of Fluid in the
following ways:

  • The “pipe” character can be used instead of “->” to
    pass tag contents, e.g. {variable | f:format.raw()}. This
    is done to approach shell syntax and for easier picking
    up of Fluid syntax if you come from Twig.
  • Arguments for inline VH calls can now be specified with
    tag attribute syntax. Commas were already optional which
    allowed syntax like “{v:h(foo: bar baz: 123)}”. This is now
    homogenised completely so you can use expressions like
    “{v:h(foo=“{bar}” baz=“123”)}” - which means that you
    can now migrate a tag-based usage to inline syntax
    without having to touch the arguments you provided as
    tag attributes.

All is achieved by adding two characters to the list that is
detected as inline syntax - “|” and “=“ - and by turning
the matching of “->” into a multiple match of either “->”
or the new “|”.

All legacy syntax is untouched. Tag syntax is untouched.

Full disclosure: a similar change was previously rejected
by myself: #343. The
only arguments I can give for accepting this current patch
but rejecting #343, are:

  • This patch modifies far less of the regular expressions
    and sticks to adding characters and converting a character
    match to a list of options.
  • It is matching the current research I am doing on using a
    lexer to parse Fluid (a project which also tries to include
    the ES2015 style array syntax but can do so without any
    concerns about bloating of even overflowing the regexp).

@NamelessCoder NamelessCoder force-pushed the feature/pipepasssyntaxequivalency branch 3 times, most recently from 71024c3 to 16c70b7 Compare July 26, 2018 14:17
This patch improves the inline syntax of Fluid in the
following ways:

* The “pipe” character can be used instead of “->” to
  pass tag contents, e.g. {variable | f:format.raw()}. This
  is done to approach shell syntax and for easier picking
  up of Fluid syntax if you come from Twig.
* Arguments for inline VH calls can now be specified with
  tag attribute syntax. Commas were already optional which
  allowed syntax like “{v:h(foo: bar baz: 123)}”. This is now
  homogenised completely so you can use expressions like
  “{v:h(foo=“{bar}” baz=“123”)}” - which means that you
  can now migrate a tag-based usage to inline syntax
  without having to touch the arguments you provided as
  tag attributes.

All is achieved by adding two characters to the list that is
detected as inline syntax - “|” and “=“ - and by turning
the matching of “->” into a multiple match of either “->”
or the new “|”.

All legacy syntax is untouched. Tag syntax is untouched.

Full disclosure: a similar change was previously rejected
by myself: TYPO3#343. The
only arguments I can give for accepting this current patch
but rejecting TYPO3#343, are:

* This patch modifies far less of the regular expressions
  and sticks to adding characters and converting a character
  match to a list of options.
* It is matching the current research I am doing on using a
  lexer to parse Fluid (a project which also tries to include
  the ES2015 style array syntax but can do so without any
  concerns about bloating of even overflowing the regexp).
@NamelessCoder NamelessCoder force-pushed the feature/pipepasssyntaxequivalency branch from 16c70b7 to 2a7d21c Compare July 26, 2018 14:18
Copy link
Contributor

@albe albe left a comment

Choose a reason for hiding this comment

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

Sounds nice, though having pipe and attribute assignment in own PRs would have been way nicer :) Thanks also for explaining why you approve this while you didn't approve the ES2016 short array syntax change. It's very reasonable

@mbrodala mbrodala merged commit dbe74a6 into TYPO3:master Aug 22, 2018
@NamelessCoder NamelessCoder deleted the feature/pipepasssyntaxequivalency branch August 22, 2018 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants