conversionfoundry / breeze

A Ruby on Rails CMS for brochure-style websites.
Other
3 stars 2 forks source link

Commenting out custom type fields in partials doesn't work #46

Open ShaneNZ opened 11 years ago

ShaneNZ commented 11 years ago

Given a custom type with fields `text' but not 'desc', and a partial with the following code:

  <div class="right">
    <p><%= text %></p>
  <!--   <%= desc %>  -->
...

The partial errors out in the page over the desc field, despite it being commented out. Ideal behaviour is to substitute the content type data where the field exists, but allow for failing silently if the field is HTML commented as above.

ShaneNZ commented 11 years ago

On testing, Ruby comments seem to work as expected. However, I think we need to "support" HTML commenting as well for front end devs to debug with.

isaacfreeman commented 11 years ago

What's happening here is that Rails processes the ERB <% %> tags first, then inserts the partial in the page when it's done. The HTML comments aren't processed until the assembled page reaches the browser. So if there's an error in a field, the HTML comments won't be used in time to prevent it – at the point where it breaks, Rails doesn't know the HTML comments are there.

Changing this would be... "horrendous" is the first adjective that comes to mind. What we could aim for is providing better guidance. The current version of Breeze (not sure about the older version you're using) has a little help guide on the side which currently doesn't say anything about comments.

ShaneNZ commented 11 years ago

Based on above comment (very true) and after discussion with Isaac, we've come to:

  1. Breeze parses as currently, if a field in the partial doesn't exist in the custom type (inside or outside HTML comments), then Breeze subs in some fixit content (possibly inside an error class div/span for styling). This text should point the developer to where to go to fix it. Fixit content could be different for different field types e.g images, text, "other".
  2. If the field is commented out in the HTML, then it wont break the page/partial. If the field is actually a problem, then it will appear on the page in a respectable fashion.