Skip to content

Instantly share code, notes, and snippets.

@Chalkin
Created July 17, 2019 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chalkin/636157366d53e324df8172ef5a1f8ac9 to your computer and use it in GitHub Desktop.
Save Chalkin/636157366d53e324df8172ef5a1f8ac9 to your computer and use it in GitHub Desktop.
{{ sections }}
...
{{ if type == 'extended_content' }}
<div class="section-empty">
<div class="container content">
{{ if type == "text" }}
<div class="text">
{{ text }}
</div>
{{ elseif type == "image" }}
<figure>
<img src="{{ image }}" alt="{{ caption }}" />
<figcaption>{{ caption }}</figcaption>
</figure>
{{ /if }}
</div>
</div>
...
{{ /if }}
{{ /sections }}
@jackmcdade
Copy link

It looks like you're just missing the {{ body }} loop so you can get the content and sets inside the Bard field. Try this:

{{ if type == 'extended_content' }}
<div class="section-empty">
    <div class="container content">
        {{ body }}
            {{ if type == "text" }}
                <div class="text">
                    {{ text }}
                </div>
            {{ elseif type == "image" }}
                <figure>
                    <img src="{{ image }}" alt="{{ caption }}" />
                    <figcaption>{{ caption }}</figcaption>
                </figure>
            {{ /if }}
        {{ /body }}
    </div>
</div>
{{ /if }}

@Chalkin
Copy link
Author

Chalkin commented Jul 18, 2019

I tried. Seems like the body keyword knocks out all of the other HTML/Content of every element inside the flexible template. So I changed it to "content" - Now it renders the HTML (also from the other flexible types) but it does not go into the if inside the content loop of the "extended_content"

So if type == "text" will not go into the if.
But when I do {{ type }} it does show all the strings inside the content (e.g text, quote, image, text)

{{ if type == 'extended_content' }}
<div class="section-empty">
  <div class="container content">
    {{ content }}
      {{ if type == "text" }}
      <div class="text">
        {{ text }}
      </div>
      {{ /if }}

      {{ if type == 'quote' }}
      <div class="quote">
        {{ text }}
        {{ cite }}
      </div>
      {{ /if }}

      {{ if type == "image" }}
      <figure>
        <img src="{{ image }}" alt="{{ caption }}" />
        <figcaption>{{ caption }}</figcaption>
      </figure>
      {{ /if }}
    {{ /content }}
  </div>
</div>
{{ /if }}

I also updated the content gist.

@jackmcdade
Copy link

What exactly do you mean by the body keyword knocks out all of the other HTML/Content of every element inside the flexible template?

@Chalkin
Copy link
Author

Chalkin commented Jul 18, 2019

Well, that when I use the {{ body }} {{ /body }} inside the extended_content HTML, none of the other Fieldsets/types render anymore. Basicly the area where the template's html should render, stays empty.

See attached Screenshot. In this example it should actually also render the html of the simple_content type as well

Screenshot 2019-07-18 at 20 30 31

@jackmcdade
Copy link

Do you have any other vars named body or content that might be conflicting?

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