Hi,
(totally newbie to both hugo and go)
I want to pass in js code from .Inner
var.
Shortcode (p5-inner.html
) is:
{{ $id := .Get `id` }}
<div id="{{ $id }}"></div>
<script>
new p5((p) => {
{{ .Inner }}
}, "{{ $id }}" );
</script>
Shortcode is called as:
{{< p5-inner id="codeid" >}}
p.setup = function () {
p.createCanvas(400, 400);
};
{{< /p5-inner >}}
Got:
<div id="codeid"></div>
<script>
new p5((p) => {
"\n p.setup = function () {\n p.createCanvas(400, 400);\n };\n"
}, "codeid" );
</script>
But I need:
<div id="codeid"></div>
<script>
new p5((p) => {
p.setup = function () {
p.createCanvas(400, 400);
};
}, "codeid" );
</script>
Tried both chomp
and trim
without success. How can I make it work?