Closed rajivnarayan closed 1 year ago
Thanks for the repot, @rajivnarayan! This is a bug in how the error message is being formatted. I just pushed a commit to fix this. The error should actually look like:
> jinjar::render('{hello {{name}}!}', name = 'world')
Error in `parse_template()` at jinjar/R/render.R:37:2:
! Problem encountered while parsing template.
Caused by error:
! Expected statement, got '{'.
ℹ Error occurred on line 1 and column 1.
Unfortunately, this means your template is still failing to render. I'll need more time to investigate. In the short term, you could potentially change your open/close delimiters via jinjar_config()
.
Update: I've identified and resolved the root cause. You can install the fixed version using:
# install.packages("remotes")
remotes::install_github("davidchall/jinjar")
@davidchall Thanks for the quick fix! I can confirm that the new version resolves the issue.
Also pre-pending a space before the opening brace works for the CRAN version 0.3.0:
jinjar::render(' {hello {{name}}!}', name = 'world')
Hi,
Thanks for this excellent package. I ran into what appears to be a bug while rendering some JSON:
The following works as expected :
jinjar::render('hello {{name}}!', name = 'world')
[1] "hello world!"
However the following with enclosing braces does not:
jinjar::render('{hello {{name}}!}', name = 'world')
Error in glue(str, .envir = .envir, .transformer = transformer, .cli = TRUE, : Unterminated quote (')
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3; LAPACK version 3.9.0
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: /UTC tzcode source: system (glibc)
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_4.3.1 magrittr_2.0.3 cli_3.6.1 tools_4.3.1 fs_1.6.3
[6] jinjar_0.3.0 rstudioapi_0.15.0 vctrs_0.6.4 knitr_1.44 jsonlite_1.8.7
[11] xfun_0.40 lifecycle_1.0.3 rlang_1.1.1 purrr_1.0.2