eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 314 forks source link

Objects and arrays yaml variables not working #260

Closed avril-affine closed 7 years ago

avril-affine commented 7 years ago

I'm trying to use the yaml object variable feature. I have the test file in pages/test.html as:


---
header_text: Lorem Ipsum
custom_object:
  name: Lorem
  description: Ipsum
custom_array:
  -
    name: lorem
  -
    name: ipsum
...

<html>
    {% for item in custom_array %}
      <p>{{ header_text }}: {{ item.name }}</p>
    {% endfor %}

    <p>{{ custom_object.name }} | {{ custom_object.description }}</p>
</html>

The resulting page is:


---
header_text: Lorem Ipsum
custom_object:
  name: Lorem
  description: Ipsum
custom_array:
  -
    name: lorem
  -
    name: ipsum
...

<html>

    <p> | </p>
</html>

<!-- Automatically inserted by Cactus. Needed for auto refresh. This will be gone when you deploy -->
<script src="/_cactus/cactus.js"></script>
ghostsquad commented 7 years ago

{{ custom_object.name }} should be {{ custom_object['name'] }}. Without serialization/deserialization support of custom objects, I'd suggest just sticking to the default types supported in yaml: lists, dicts, strings, none/null, ints, floats

macedd commented 7 years ago

Also not sure how to workout the YAML variables. I've used them in the base template

eg.

---
body_class: page
...
<body class="{{ body_class }}">

And them tried to change the var in a page, but had the same result above

macedd commented 7 years ago

Ok, in my case I was using version 3.3.3 But YAML support is currently on master only

pip uninstall Cactus
pip install https://github.com/eudicots/Cactus/archive/master.zip
avril-affine commented 7 years ago

Installing from master worked. Thanks.