雨果管道问题

问题描述

我正在尝试使用管道来捆绑我的插件和脚本模块。 到目前为止,这是我的代码

{{ $jsBundle := slice }}
{{ $jsBundle = $jsBundle | append resources.Get  "plugins/google-map/map.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/jquery/jquery.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/lazy-load/lozad.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/magnific-popup/jquery.magnific-popup.min.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/shuffle/shuffle.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/slick/slick.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "js/script.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/boosting.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/coaching.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/placements.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/tourneyTitle.js" }}
-->
{{ $jsBundle := $jsBundle | resources.Concat "js/bundle.js" | fingerprint "sha384" }}
<script src="{{ $jsBundle.Permalink | absURL }}"></script>

每当我运行此代码时,都会出现此错误

executing "partials/footer.html" at <resources>: wrong number of args for Get: want 1 got 0

因此,在尝试弄清楚如何解决此问题并尝试使用文件路径而不是 Get 来使用它之后,我决定回到我第一次观看教程的方式。那个链接在这里https://www.youtube.com/watch?v=A20U7KbA4tA 您可以跳到 17:00,看看他在哪里得到完全相同的错误,然后修复它。不过这个修复对我不起作用。

{{ $jsBundle := slice }}
{{ range .Site.Params.plugins.js}}
{{ $jsFile := resources.Get .link | minify }}
{{ $jsBundle := $jsBundle | append $jsFile }}
{{ end }}
{{ $jsBundle := $jsBundle | resources.Concat "js/bundle.js" | fingerprint "sha384" }}
<script src="{{ $jsBundle.Permalink | absURL }}"></script>

当我以这种方式尝试时,我得到的错误消息是

executing "partials/footer.html" at <resources.Concat>: error calling Concat: slice []interface {} not supported in concat

如果需要,我可以链接 repo。但它没有完全推开。我更喜欢使用我列出的第一种方式,这样我就不必为插件和模块设置多个范围,它让我可以轻松选择我想要使用的内容,而不是自动执行所有操作。

解决方法

改变这个:

{{ $jsBundle = $jsBundle | append resources.Get "foo" }}

为此:

{{ $jsBundle = $jsBundle | append (resources.Get "foo") }}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...