Set global variables using the Cactus App for Mac

For those of you new to Cactus , this is a static website creation application for Mac. It compiles your files and allows you to write template code in Django.

Their docs show how to make custom variables , which is great. But I don’t understand how to achieve global variables that apply to all templates.

I tried to do this by Google, but all of the answers in Django / python are focused on a clean python setup and are not really applied to this particular application. I also tried to contact the authors, but did not respond.

This question is for those who have worked with Cactus before. fingers crossed

Greetings

+4
source share
2 answers

Cactus has a 'config' tag that allows you to access the variables specified in the config.json file.

So, if your config.json contains the following line:

"email": " webmaster@example.com ",

... then in your templates you can reference this with:

{% config "email"%}

Hope this answer was worth 18 months of waiting!

0
source

@ Anton's answer is great for printing global variables, but ... for using them on blocks, it's best to place them in a context entry in config.json. This way, you can easily access templates for them.

If you want to do:

<meta name="author" content="{{ blog.author }}">

config.json:

{
  ...
  "context": {
    "blog": {
      "id": "fancy-site",
      "author": "Joe Blogs",
      "description": "Such a fancy site"
    }
  }
}

: https://github.com/eudicots/Cactus/issues/125

. JSON. , , .

0

Source: https://habr.com/ru/post/1533541/


All Articles