Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use a variable in a value of a key-value declaration? #606

Closed
nlisker opened this issue Mar 30, 2019 · 7 comments
Closed

Comments

@nlisker
Copy link

nlisker commented Mar 30, 2019

This is part of the config file:

[params]

  # Hero section
  [params.hero]
   title = 'Version 11'

  # Documentation section
  [params.documentation]
    enable = true
    title = "Documentation"
    description = ""

    [[params.documentation.item]]
      title = "Release Notes"
      description = "Read about Version 11"

    [[params.documentation.item]]
      title = "Getting Started"
      description = "Get started with Version 11"

    [[params.documentation.item]]
      title = "Doc"
      description = "Documentation for Version 11"

If I change the version to 12, I don't want to go over each value and change it. What I want is to defined version = "12" (I guess under [params]) and then use this variable in all the values, like:

description = "Read about Version " + version

or something to this effect. Is something like this possible?

@TheElectronWill
Copy link
Contributor

TheElectronWill commented Mar 30, 2019

this is not possible in TOML, however you could add +version in your application's code

@nlisker
Copy link
Author

nlisker commented Mar 30, 2019

Thanks, what do you mean by "add +version in your application's code"?

@TheElectronWill
Copy link
Contributor

instead of writing "read about version 11" in the config you write "read about version" and you add the version number after reading the config

@drunkwcodes
Copy link

It can be achieved by adopting modern template engines.
There are lots of implementations and different syntax.

It should be agnostic to TOML IMHO.

@nlisker nlisker closed this as completed Apr 10, 2019
@nlisker
Copy link
Author

nlisker commented Apr 10, 2019

Got it, thanks.

@SubhramRanaRZP
Copy link

SubhramRanaRZP commented Feb 24, 2022

@drunkwcodes How can I do this. I have no knowledge on template engines. It will be helpful if you could provide some useful link

@drunkwcodes
Copy link

@SubhramRanaRZP jinja, mako, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants