Skip to content

Multiple blocks inside of a single file

undermouse edited this page Sep 4, 2022 · 3 revisions

Themer file config supports 2 modes:

  • Single block
  • Multiple blocks

Single block

Single block mode allows you to have just one block inside your configuration file. Since most of the time you'll have just a set of variables inside your themer block, this is the most common mode. This mode is used for the default setup shown in Themer's Wiki Home

Multiple blocks

To setup multiple blocks inside your config files, you firstly need to refactor Themer's config.yaml:

files:
  my_file:
    path: "~/my_file.css"
    comment: "/*"
    closing_comment: "*/"
    blocks:
     vars:
      format: "--<key>: <value>;"
      custom: |
        :root {
          <vars>
        }

Let's go through this config line by line and understand what's going on.

  • First to lines define a file called my_file, much line Single block mode.
  • In Multiple blocks mode, variables path, comment and closing_comment are shared for every block.
  • blocks tells Themer there are multiple Themer blocks inside this file.
  • Then you define a block with a name (or a tag).
  • Inside block you can do any configuration you did with Single block mode (except, of cource, path, comment and comment_end. These variables are global for every block inside file)

Refactoring configuration files.

Imagine ~/my_file.css exists, so we need to refactor it to Multiple blocks mode to work. Find your Themer block and update it to look like this:

-/* THEMER */
-/* THEMER_END */
+/* THEMER:vars */
+/* THEMER_END:vars */

Notice the difference? "vars" after a semicolon is the name of the block we have defined inside our config.

Conclusion

Now you can setup multiple places to be updated inside a single file with Mutple blocks mode.
This can be quite handy in scenarios where you have additional code besides just a list of variables, but you can't put these chunks of code inside one Themer block.

You can see the use of in "examples/i3-wallpaper.md" at repo's root.

Clone this wiki locally