wvuweb / hammer

A tool for CleanSlate theme development
https://cleanslate.wvu.edu
4 stars 2 forks source link

Only show the contents of `<r:if_childless>` if there are no pages in `mock_data.yml`. #96

Open adamjohnson opened 3 years ago

adamjohnson commented 3 years ago

Steps to reproduce the issue

  1. Clone the brand-patterns theme.
  2. With hammer running, visit the Profile Index template.
  3. Add the following code to the template (probably around line 11):
<r:if_childless>
  <p>No profiles found</p>
</r:if_childless>

Results

Even though there are two pages in the pages key in mock data, the contents of this tag are output.

Expected results

If there is content in the pages key in mock_data.yml, the tag should not output anything.


This bug/request is very low priority.

adamjohnson commented 3 years ago

If you absolutely cannot stand seeing the content inside the r:if_childless tag while you're developing locally, you can add the following JS to hide the "No profiles found" message (just don't commit it to the repo!):

var PROFILES = {
  getEmptyText: document.querySelectorAll('.no-profiles-found'),
  removeMessage: function () {
    PROFILES.getEmptyText.forEach(function (item) {
      item.remove();
    });
  }
};
document.addEventListener('DOMContentLoaded', PROFILES.removeMessage);

Be sure to change/add the .no-profiles-found class to target whatever you want hidden.