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

Objects and arrays yaml variables not working #260

Closed
avril-affine opened this issue Oct 16, 2016 · 4 comments
Closed

Objects and arrays yaml variables not working #260

avril-affine opened this issue Oct 16, 2016 · 4 comments

Comments

@avril-affine
Copy link

avril-affine commented Oct 16, 2016

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
Copy link

ghostsquad commented Oct 22, 2016

{{ 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
Copy link

macedd commented Oct 26, 2016

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
Copy link

macedd commented Oct 27, 2016

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
Copy link
Author

Installing from master worked. Thanks.

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

No branches or pull requests

3 participants