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

Add string position of tokens in token trees #859

Merged
merged 1 commit into from
Mar 13, 2023
Merged

Add string position of tokens in token trees #859

merged 1 commit into from
Mar 13, 2023

Conversation

synga-nl
Copy link
Contributor

This PR adds the position to the tokens in the token tree.

Example found in the following string:
I want to {{ try }} a more {% if advanced | length > 3 %}{{ variable }}{% endif %} template {% set unit = 2 %}{# This is a comment #}{{ variable_after_comment }}

  {
    type: 'raw',
    value: ' template ',
    position: { start: 82, end: 92 }
  },

This means the raw text template can be found between position 82 and 92 in the given template.

This is one of a series of PRs I want to make to parse through tokens and to act on these tokens. Like the NodeTraverser of Twig in PHP.

@willrowe
Copy link
Collaborator

This looks pretty good. I don't see any reason why it can't be merged, any thoughts @RobLoach?

@RobLoach RobLoach merged commit 59d991d into twigjs:master Mar 13, 2023
@RobLoach
Copy link
Collaborator

Makes sense to me 👍

@RobLoach RobLoach changed the title Adds the (string) position of tokens to the token tree. Add string position of token in token trees Mar 13, 2023
@RobLoach RobLoach changed the title Add string position of token in token trees Add string position of tokens in token trees Mar 13, 2023
@synga-nl
Copy link
Contributor Author

@willrowe or @RobLoach is it possible to create a minor version of this on NPM? That makes testing the package in other applications way more easy for the other PRs (token traverser).

@willrowe
Copy link
Collaborator

I was going to add this to the v1.17.0 milestone that I will be choosing fixes/features for in the next couple of weeks, so I'm not sure if we'd do a release for just this or not.

@willrowe willrowe added this to the 1.17.0 milestone Oct 11, 2023
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.

None yet

3 participants