-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
include tag whitespace #42
Comments
As I can see from your code snippet before, seems the @sebastienros is this how it works?, or is it a bug? Coz I see DotLiquid preserve the spaces |
The issue is that I strip whitespace between block tags by default. I think
I documented it on the readme. There might be an option to disable it but
then you will have to specify the behavior or each tag. Let's see what
Hisham says.
…On Nov 7, 2017 7:18 AM, "Hisham Bin Ateya" ***@***.***> wrote:
Let me check that ..
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#42 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHJ7fzMcG6jetUes01cKKlw_uBfWdtKks5s0HTAgaJpZM4QUZF1>
.
|
For simplification we should preserve the whitespace, or add an option as you suggest before, but I don't think specifying the behavior per tag is a good option |
Per tag is just from liquid specification... And it's already supported,
look at the unit tests.
…On Nov 7, 2017 8:09 AM, "Hisham Bin Ateya" ***@***.***> wrote:
For simplification we should preserve the whitespace, or add an option as
you suggest before, but I don't think specifying the behavior per tag is a
good option
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#42 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHJ7XblYGjT5LQwm5XRwKlvygF2-MFNks5s0ICegaJpZM4QUZF1>
.
|
Sounds good, let me check .. |
just fyi, dotLiquid supports this scenario only if the contents of my AutoProperty.liquid example are only one line. If my AutoProperty.liquid would be this:
The results in dotLiquid would be
I would expect multiline included files to be evenly whitespaced |
That's not what it does, it's just rendering the whitespace, for each time the block is rendered. Nothing to do with What could be done though is to add a property to the include tag such that new lines are also padded. And the padded value could be global variable in your main template such that you can call it recursively. We should still handle the whitespace issue that you have found. And look at liquid if it supports what I just described. |
Sorry if I am being verbose on this thread, but it's important that we all understand the pros and cons of each solution. Right now Fluid will strip the whitespace before a block tag content, which happens in this case. The idea is that in most cases we don't want to render indentations before code flow tags, like Take this example:
Without this default behavior, we would get an output containing 10 empty lines, though nothing should be rendered. You can take a look a this file for tests that show how it handles whitespace: https://github.com/sebastienros/fluid/blob/dev/Fluid.Tests/WhiteSpaceTests.cs What I would suggest right now to solve your problem, is that we create a custom tag that would indent a section, like this:
The result would be that every line in the block would be indented by 4 spaces. We would add an optional parameter with the string to repeat, like tabs. |
/cc @RSuter I assume you would love that |
relevant liquid issue: Shopify/liquid#925 It seems liquid and dotLiquid behave exactly the same in this scenario. I think your indent solution is a good idea, as it would keep the compatibility with liquid templates. Depending on how Shopify/liquid#925 turns out, you could add the new tag syntax discussed there and deprecate the indent tag, or keep both. For me this isn't that big (urgent) of an issue, I'm currently using Roslyn at the end of my code generation to format everything nicely, but it would be nice to ditch that dependency |
You are right, we still need to fix the fact that the whitespace is ignored in this case. To behave exactly the same as the reference implementation we could have a flag. Let me check. |
Make an option such as |
The 2.x version doesn't strip whitespaces by default anymore, and there are options to change the behavior for each type of tags. |
Hi,
When using the include tag, I would expect the contents of the included liquid file to render with the whitespace of the root file appended.
For example:
Class.liquid:
AutoProperty.liquid:
public {{ col.PropertyType }} {{ col.PropertyName }} { get; set; }
Currently outputs like this:
where I would expect this:
The text was updated successfully, but these errors were encountered: