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

How to access the syntax tree #482

Closed
thomasrosdahl opened this issue Feb 24, 2022 · 4 comments · Fixed by #630
Closed

How to access the syntax tree #482

thomasrosdahl opened this issue Feb 24, 2022 · 4 comments · Fixed by #630

Comments

@thomasrosdahl
Copy link

Could someone please clarify this section of the readme:

"Parses templates in a concrete syntax tree that lets you cache, analyze and alter the templates before they are rendered."

How can I access the syntax tree of a parsed template? I would like to analyze which values/props are being accessed.

Thanks

@thomasrosdahl thomasrosdahl changed the title How to access the AST How to access the syntax tree Feb 24, 2022
@thomasrosdahl
Copy link
Author

Found it. It's hidden by the IFluidTemplate interface. The concrete implementation has a 'Statements' property which exposes the AST.

@guillaume86
Copy link
Contributor

guillaume86 commented Jan 18, 2024

I was also looking for it, a little statement explaining that in the documentation would be nice.

@sebastienros
Copy link
Owner

@guillaume86 Can you try to add that to the doc in a PR?

guillaume86 added a commit to guillaume86/fluid that referenced this issue Feb 23, 2024
Add a note in the README about accessing the cst.
Fixes sebastienros#482.
@hishamco hishamco reopened this Feb 26, 2024
sebastienros pushed a commit that referenced this issue Feb 26, 2024
Add a note in the README about accessing the cst.
Fixes #482.
@sebastienros
Copy link
Owner

Note that this PR contains an updated AST and a visitor pattern which allows to detect specific elements in the template and also modify it.

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 a pull request may close this issue.

4 participants