flatiron / plates

Light-weight, logic-less, DSL-free, templates for all javascript environments!
MIT License
831 stars 69 forks source link

Overrides elements with bad content #107

Closed mmalecki closed 11 years ago

mmalecki commented 11 years ago

With template:

<div>
  <div class="page-details">
    <div class="author">
      <div class="name"></div>
    </div>
  </div>
  <div class="page-details">
    <h1 class="title"></h1>
  </div>
</div>

Data:

{
  "page-details": {
    "author": {
      "name": "Maciej"
    },
    "title": "Title"
  }
}

Output should be:

<div>
  <div class="page-details">
    <div class="author">
      <div class="name">Maciej</div>
    </div>
  </div>
  <div class="page-details">
    <h1 class="title">Title</h1>
  </div>
</div>

But is:

<div>
  <div class="page-details">
    <div class="author">
      <div class="name">Maciej</div>
    </div>
  </div>
  <div class="page-details">
    <div class="author">
      <div class="name">Maciej</div>
    </div>
  </div>
</div>
mmalecki commented 11 years ago

Apparently the reason it happens is because we do a replace() on body, but get the replacement value only once.

Swaagie commented 11 years ago

This is caused by both page-details being a div, probably a regexp that is malfunctioning somewhere, hope to fix this today. Test 36 shows this can be done properly already