octopress / ink

A core component for building Gem based Jekyll themes.
MIT License
103 stars 36 forks source link

Can't get path of layout from plugin #44

Closed drallgood closed 9 years ago

drallgood commented 9 years ago

Not sure whether I'm doing something wrong (and I probably do). I'm working on a ink based plugin right now and I'm having issue getting the path of a layout file. It's loading just fine, but when I try to get the path, I only get: undefined method 'path' for #<Octopress::Ink::Layout:0x007fcf970200a8> (NoMethodError).

I'm trying to create a (dynamic) set of pages from a template.

Suggestions?

imathis commented 9 years ago

I'm not sure I understand what you're trying to do. Why do you need the path for a layout? If you can explain a bit more about what you're doing I may be able to try it out and see what's going wrong with my code or suggest something for you to change.

drallgood commented 9 years ago

What I was trying to do was create a page based on a layout. I got the layout from the site using site.layouts["categories:category_index"] and then tried to get its path so I can instantiate a new page.

I've worked around it by just copying the content and data of the template to a newly created page object instead of letting the page load its content (like it's usually done).

imathis commented 9 years ago

I've added page templates assets to Octopress Ink which makes this much cleaner now. You can see an example of how to get them to work here: https://github.com/octopress/ink/commit/fd13edd3b787ee031955420377a5e79067fed982#diff-3d2be8f58875d685ff747d4d6811e6eeR3

I still need to add docs (for so many things) but I think this replaces the need for this issue to be fixed.