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

jinjar as enhancement to sqltargets #38

Closed
daranzolin opened this issue Jul 10, 2024 · 2 comments
Closed

jinjar as enhancement to sqltargets #38

daranzolin opened this issue Jul 10, 2024 · 2 comments

Comments

@daranzolin
Copy link

Hi David,

Thanks for creating and maintaining this great package! It was precisely what I was looking for when I first discovered 'Jinja-like' SQL and hoped to implement its capabilities within the sqltargets package.

I have an open pull request to add jinjar and it's passed some basic tests and checks. Before I merge, however, I would welcome your expertise on how to make the most of jinjar and how to implement it correctly. No worries if you're too busy, I still wanted to take the opportunity to thank you for this package.

@davidchall
Copy link
Owner

Hi @daranzolin, Thanks for your interest in jinjar - I'm so glad to hear you've found it helpful!

I took a quick look at your PR and have a couple of comments:

  1. Query parameters are passed to jinjar::render() as a single named list object params. As a result, template variables require a namespace. For example, {{ params.payment_methods }} instead of {{ payment_methods }}. If this was unintentional, you should be able to use the slice operator to access the parameters directly. image

  2. Jinjar and Jinja support different template syntax (jinjar is powered by the inja library), though I've tried to match things as closely as I can. This means an existing Jinja template might need some edits before it'll work with jinjar. I'd ask that you reflect this difference in your documentation (perhaps with a link to this vignette), to avoid confusion and frustration.

@daranzolin
Copy link
Author

Thanks for the feedback @davidchall !

  1. I initially tried to pass dots ... all the way to jinjar_render() via tar_sql() but was running into problems. I eventually settled on params to mimic how params are utilized in Quarto. Still thinking about this.
  2. I will be sure to link to the above vignette, I've already referenced it several times in my own work.

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

No branches or pull requests

2 participants