Is it possible to use functions with arguments on multiple lines?

Hello,
I’m trying to create an array of all the CSS and JS resources in the head of my page, for example:
slice (resources.Get "assets/css/bootstrap.css") (resources.Get "assets/css/bootstrap.css")
but since I will have many files, I want to be able to use the slice function over multiple lines:

slice 
(resources.Get "assets/css/bootstrap.css") 
(resources.Get "assets/css/bootstrap.css")
...

is it possible?
I know that you can do that with strings, but I don’t know if its the same.

Yes, you can.

1 Like

I’m trying to do it like this:

{{ $ceva:=slice
        (resources.Get "assets/css/bootstrap.css")
        (resources.Get "assets/css/bootstrap.css") }}
{{$ceva}}
    {{range $ceva}}
        <link href="{{.Permalink}}" rel="stylesheet" type="text/css" media="all">
    {{end}}

but I get
parse failed: template: partials/head.html: 14: unclosed action
where line 14 is the first line in the code above

Version? The ability to include newlines in template actions and commands was introduced with v0.81.0. The current release is v0.91.0.

https://github.com/gohugoio/hugo/releases/tag/v0.91.0

1 Like

You are right, with the latest version is working. It seems I had an older version.
Thanks

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.