How to break a command into multiple lines for alignment?

I’ve got a code like this:

{{ partial "show-product.html" (dict "param1" "value1" "p2" "v2" "lastp" (slice "a1" "a2" "a3" ) ) }}

Which is hard to read. What I really like to do is to format it like this:

{{ partial 
    "show-product.html" 
    (dict 
        "param1"  "value1" 
        "p2"      "v2" 
        "lastp"   (slice 
                      "a1" 
                      "a2" 
                      "a3"
                  ) 
    ) 
}}

… which gives me an error. Is there a way to break a command into multiple lines?

You could try to add a \ (backslash) before the line break - I just thought of that, never tested it. But I think it’s not possible to break up a tag on multiple lines.

By the way: why not using param1=“value1” param2=“value2” param3=“a1 a2 a3” and then exploding the third parameter in your shortcode?

So, that’s a no for now :slight_smile:

For my current case, because the possible combinations of data are limited, I’ve created a data file and instead of sending all those values to the partial, I just send one element of that data file.

Took some time but :tada:

https://go-review.googlesource.com/c/go/+/254257/

5 Likes