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

Substitute variables #388

Merged
merged 4 commits into from
Jan 8, 2023
Merged

Substitute variables #388

merged 4 commits into from
Jan 8, 2023

Conversation

devongovett
Copy link
Member

Closes #321

This adds a substitute_variables function to UnparsedProperty, which will substitute variables provided in a HashMap with their values and return a new Property containing the fully parsed version (if possible). It is implemented using the visitor and into_owned features, and is available under the substitute_variables feature. It works by first substituting the tokens, then printing the tokens to a string and finally reparsing them as an owned (i.e. 'static) property. This is necessary because at this time cssparser doesn't offer a way to reuse the existing tokens when parsing.

@devongovett devongovett merged commit aa0c8d1 into master Jan 8, 2023
@devongovett devongovett deleted the substitute-vars branch January 8, 2023 15:42
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.

Do not tokenise unparsed values, or offer a way to parse tokens
1 participant