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

Meta data removal bug. Affecting layouts. #517

Open
ghost opened this issue Jun 5, 2013 · 2 comments
Open

Meta data removal bug. Affecting layouts. #517

ghost opened this issue Jun 5, 2013 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 5, 2013

Add a parameter to a document that another file utilizes (so for this case an index of writings); then, remove that parameter. The layout fails to recognize that removed parameter.

---
title: 'Kindle Paperwhite is Magic.'
date: 'June 01 2013 04:32 AM'
description: 'A review of the Kindle Paperwhite'
layout: 'writing'
tags:
  - reading
  - books
  - e-reader
  - e-ink
  - paperwhite
  - kindle
  - amazon

---

Then, remove the description and assume the template no longer utilizes the description.

---
title: 'Kindle Paperwhite is Magic.'
date: 'June 01 2013 04:32 AM'
layout: 'writing'
tags:
  - reading
  - books
  - e-reader
  - e-ink
  - paperwhite
  - kindle
  - amazon

---

The template persists in rendering a value that no longer exists; it isn't being removed from the model that the template has. However, when I did a raw query with the DocPad API the property was removed.

The only work around is to manually set the value to false description:false then the value is updated. So it appears that removing the value did not update the model.

Here is the index code:

<% writings = @getFilesAtPath('./writing/', {date: -1}); %>

  <% if writings.length: %>

    <ul class="items">

    <% for writing in writings.models: %>
      <li>
         <%- writing.get('title') %>

        <% console.log(writing.get('description')); %>

        <% if writing.get('description'): %>
          <blockquote><p class="description"><%- writing.get('description'); %></p></blockquote>
        <% end %>
      </li>
    <% end %>

    </ul>

  <% else: %>
    <p>No writing</p>
  <% end %>

Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

@ghost
Copy link
Author

ghost commented Jun 29, 2013

bump +1

@balupton
Copy link
Member

balupton commented Dec 3, 2013

This is correct. Unfortunately, I don't have a good idea on how to fix this.

One possible way is to keep a listing of which attributes are meta attributes, then when re-parsing, we delete the old meta attributes if they are their old values still, and no longer exist with the latest parse. But the problem with this is that things like setMetaDefaults on add listeners, won't work.

Happy for someone to send a pull request for this.

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

No branches or pull requests

1 participant