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

Open to the idea of supporting less strict parsing/rendering as an option? #490

Open
RyanAmos opened this issue Jan 9, 2023 · 3 comments
Labels
enhancement Improve the expected

Comments

@RyanAmos
Copy link

RyanAmos commented Jan 9, 2023

Following up from my comment left on this issue.

I have a use-case where it's necessary for us to reduce the rendering strictness, specifically for variables. We allow users to define their own templates and store them. Those templates are then used later to render values with global variables provided by the customers' data which may or may not have all of the variables present. Our current implementation just renders those missing variables as an empty string.

I've tried multiple work arounds to get around this, some of which were fairly hacked together, but they all had edge cases that weren't handled properly.

I'm curious if you're open to the idea of adding a "lax" rendering mode?

@RyanAmos RyanAmos changed the title Open to the idea of changing supporting less strict rendering as an option? Open to the idea of supporting less strict parsing/rendering as an option? Jan 9, 2023
@epage epage added the enhancement Improve the expected label Jan 10, 2023
@epage
Copy link
Member

epage commented Jan 10, 2023

I'd be open to an outside contributor adding this if

  • It isn't too invasive
  • It doesn't dramatically affect performance
  • It is off by default

The first issue I see with implementing this is "where". The Runtime trait is a natural place but we build up runtimes throughout the execution of the template, stacking them on top of each other, so there is no top-level runtime to provide this behavior.

We might be able to handle a templated type that wraps the Runtime and all calls actually take this, rather than a runtime directly to ensure it gets used. It'll get a bit messy but likely would work.

@RyanAmos
Copy link
Author

I have a local branch that I believe follows all of your requirements. I could be missing something within the implementation, but I'll push up a PR to start getting feedback today.

@RyanAmos
Copy link
Author

PR opened, open to any and all suggestions:
#492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants