"eval" a variable from configuration parameter

I want to make the “source” of my tagcloud configurable. Right now it’s hard coded into a partial and I have one partial per tag cloud “type”:

{{ if not (eq (len $.Site.Taxonomies.tags) 0) }}
    ...
    <div class="text-center">
    {{ range $name, $_ := ($.Site.Taxonomies.tags) }}
        ...
    {{ end }}
    ...
    </div>
{{ end }}

Is there any way to have a config.toml param like the following and then in the template somehow to eval the configuration to retrieve the items?

[params]
tagcloudsource = "$.Site.Taxonomies.tags"

No, but while that would be useful in some situations, don’t see why you couldn’t pull those into “partial functions”.

This might be what I am looking for: https://stackoverflow.com/a/37384665/512174

I am not aware yet of “partial functions”… Googling now.

Got it. That makes sense. I didn’t know the returns have a name :wink: Should be added to the documentation.

And as always, Regis Philibert (@regis) already covered the exact topic:

The solution to my particular idea is in the chapter “Caching” near the end.

2 Likes

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