Skip to content

[Request] Ability to check if a given 'contentFor' has been set #17

Description

@zvictor

Considering that

  • almost every time we use a contentFor we have a wrapper around it (usually a header, footer or just a div with some classes);
  • when there is no content for a given region, usually there is no reason to keep the empty wrapper there.
  • a wrapper with no content is obviously harder to hide than a wrapper that just does not exist.
    • Sometimes it can be considerable hard to hide the empty wrapper without screwing the rest of your css.

Than I infer that we should have a way to use some kind of if statement to check if we should add a region code with its wrapper inside our html.

That's an example to express my idea:

<template name="MyLayout">
  <h1>My Layout</h1>

  <div>
    {{> yield}}
  </div>

{{#if [THE FOOTER CONTENT HAS BEEN DEFINED]}}
  <footer>
    {{> yield region="footer"}}
  </footer>
{{/if}}
</template>

Is there a way to do it now? If not, is it possible for us to implement it, and what would be a good "syntax" for that?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions