-
Notifications
You must be signed in to change notification settings - Fork 63
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
indentation or tabs are only respected when surrounded by leading + closing blank lines #234
Comments
The idea is to make the indentation of the glue template match the indentation to the desired output, so I would suggest using something like this for this case.
The intuition should be that the values are always trimmed to the least indentation level. That being said I think the first example should have worked as you expected, that looks to me like a bug where the indentation of the first line is not correctly considered when calculating the minimum indentation. |
@jimhester can you say exactly which example you think should have worked? |
glue("parameters:\n {params}") I think should give you
|
I've had a think on this and believe Here's how
In @njtierney I think you're sort of fighting the intended usage, which is to indent glue strings in your source similar to how you want them to appear to a user. Versus writing strings with literal Personally, I'd write this as params <- "mu = 1, sigma = 0.5"
glue::glue("
parameters:
{params}")
#> parameters:
#> mu = 1, sigma = 0.5 which is functionally equivalent to what @jimhester suggested. If you really want to insert your own literal params <- "mu = 1, sigma = 0.5"
glue::glue("\nparameters:\n {params}")
#> parameters:
#> mu = 1, sigma = 0.5 |
Hello! 👋
Just noticed this behaviour in glue, and wanted to check if this was behaving as expected?
I am changing some print methods in
greta
to useglue
and we wanted to have parameter values on a new line and then indented two spaces. However I noticed that in order to get this to work I needed to have a leading and trailing newline, just wanted to check if this is expected, as I was hoping that some of the below options would work, but they did not:Created on 2021-11-05 by the reprex package (v2.0.1)
Session info
Thanks again for providing
glue
! It's helping make code more readable and debuggable, just wanted to check if this was correct behaviour :)The text was updated successfully, but these errors were encountered: