ruhoh / ruhoh.rb

http://ruhoh.com
616 stars 69 forks source link

Mustache can't load partial in theme if there's a same name partial in system directory #212

Open douo opened 11 years ago

douo commented 11 years ago
irb(main):001:0> pp ruhoh.collection('partials').files
 ......
 "posts_collate.html"=>
  {"id"=>"posts_collate.html",
   "realpath"=>"/cygdrive/x/cloud/ruhoh.rb/system/partials/posts_collate.html",
   "resource"=>"partials"},
 "posts_collate.mustache"=>
  {"id"=>"posts_collate.mustache",
   "realpath"=>
    "/cygdrive/x/cloud/blog/twitter/partials/posts_collate.mustache",
   "resource"=>"partials"}}

There are two posts_collate in db, one belong to theme, other one belong to system. As the document says , if we find posts_collate, it should return the partial in theme . But in fact is not!

irb(main):005:0> ruhoh.collection('partials').find('posts_collate').pointer
=> {"id"=>"posts_collate.html", "realpath"=>"/cygdrive/x/cloud/ruhoh.rb/system/partials/posts_collate.html", "resource"=>"partials"}
plusjade commented 11 years ago

@douo really good catch. I've documented a failing test case in my wip branch:

  Scenario: Overloading a system-level partial using a different file extension.
    Given some files with values:
      | file | body |
      | partials/posts_collate.mustache | Pwned |
      | _root/index.md | {{> posts_collate }} |
    When I compile my site
    Then my compiled site should have the file "index.html"
      And this file should contain the content "Pwned"

This has to do with the low-level logic for finding "resources" on collections within the cascade levels. It's definitely a bug but I will need a little time to come up with a proper solution since the logic in question is part of the core engine running ruhoh.

Thank you for documenting this!

douo commented 11 years ago

thanks, @plusjade I just rename all *.mustache to *.html. Temporary Fix. =X