How do I get the `noClasses` value?

So, I’m working on a theme that uses custom CSS for syntax highlighting.

It requires markup’s noClasses = false to work, but I also want to make it optional.

The thing is… Right now I’m using a custom param called useCustomChroma, cuz I don’t know how to get the noClasses value.

So, here’s the thing :wink: We are not in your head. Where do you use noClasses and where do you use a custom param useCustomChroma and where is that custom param called/processed/checked?

I would post a demo-repo so that we can examine your website. Code samples are relevant :slight_smile:

Oh, sorry. I’m referring to this:

[markup]
  [markup.highlight]
    noClasses = false

The useCustomChroma is in my [params]… I already know how do you get these values, by using something like {{ .Site.Params.useCustomChroma }}, but I don’t know how to deal with [markup].

Would it be like {{ .Site.Markup.Highlight.noClasses }}…? I’m really sorry if I’m not explaining it well.

If we are talking about your config.toml/yaml file then you have no access to the markup part. The params part is parsed and available in .Site.Params so what you do is probably the right way to do it. The thing is, why do you need to know in your partial that you are using a custom chroma setup? That might be only an issue if you develop a theme for many sites. If it’s just your own site then why not just do the partials the way you need it to be?

The way I understand it you want access to config parameters in your template file. As far as I know this is only possible in the params part of the config file. The other parameters are directly for Hugo and not available in the templates.

1 Like

I just wanted to have one less param I guess. ¯_(ツ)_/¯

Ease the setup a little bit, since I want to publish it as my first theme.

I’m using it to inject custom Chroma styles for both light/dark mode.

Since it would be required to make noClasses = false anyway, if I could get its value I wouldn’t need another param.

No, that config isn’t available in the templates (and never will, for reasons discussed before).

1 Like

The short version of the above is that it would make it almost impossible to make any changes to the config setup without breaking lots of stuff in the wild.

1 Like

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