need help here
this line failed,
{{< teksleaf type="large" count=10 >}}
error message
ERROR: 2015/08/07 mn:9: unterminated quoted string in shortcode parameter-argument: '10 >}}'
does shortcodes accept string only?
thanks
need help here
this line failed,
{{< teksleaf type="large" count=10 >}}
error message
ERROR: 2015/08/07 mn:9: unterminated quoted string in shortcode parameter-argument: '10 >}}'
does shortcodes accept string only?
thanks
Yes…
I realize that wasn’t very helpful … Shortcode parameters mimic HTTP parameters; i.e. all strings and the datatype is contextual.
If you could tell a little more about your problem, maybe someone can chime in with a workaround?
no worries I just clarifying it’s not a bug. Maybe I use shortcodes not as it was intended.
I was trying to pass argument that can be use to limit
{{ range (where .Site.Pages ".Weight" "<=" (.Get "count" )) }}
Or hugo has something like string to number conversion function?
thanks
A hackish way would be
{{ range (where .Site.Pages ".Weight" "<=" (add (.Get "count") 0 )) }}
BUT:
What you’re doing looks to be the role of the template, and you may be in for some surprises … I have talked about the chicken and the egg re. shortcodes before (remember: shortcodes live on a page).
Yeah. Thanks for the hackish way. I’m moving to template now. Seems more appropriate.
There is no casting function available in Go templates?
I’m trying to use first n
in a shortcode with n
being passed in as a variable. It has to be a shortcode because the content is markdown.
I tried your suggested hack with:
{{ range first (add (.Get "first") 0) .Page.Site.Pages }}
{{ if in .Params.tags .Get "tag" }}
{{ .Render "teaser" }}
{{ end }}
{{ end }}
Which gave me the error:
ERR: template: shortcodes/content-by-tag.html:4:18: executing "shortcodes/content-by-tag.html" at <add (.Get "first") 0>: error calling add: Can't apply the operator to the values
I get a l little dizzy about what was added when, but in Hugo 0.16 there is both a string
and a int
(and also a slice
) template func …
I have checked, and add doesn’t accept strings, so that will not help. But this should work:
{{ range first (.Get “first”) .Page.Site.Pages }}
As first should cast to int fine.
Ahhh, first
does indeed cast the value to an integer. Since I was listing the first n
items, then filtering them I kept getting no results.