hobbit-contrib
hobbit-contrib copied to clipboard
#4 partial in subfolder
@houndci: everywhere @patriciomacadden use single quote.
This should fix partial bug in subfolder for render (tilt) and mote.
Hi @wafcio, don't worry about @houndci. Your syntax is exactly how I like it.
What's the but you're saying? Can you provide a use case where this change would be useful?
I added new tests in this pull request, this fix situation when you want load partial in subfolder, for example, when you pass
partial 'namespace/partial'
now it load _namespace/partial template, becouse you prepend _. My fix finding last element in path and add _ to that element. So load namespace/_partial.
Is it ok, or do you prefer make more test(s)?
Hi @wafcio, here are my thoughts about this PR:
- I don't like this call. The full path is being calculated in two different methods: first in
partial_path
(which gives us something likepath/to/my/_partial
), and then infind_template
(which gives usviews/path/to/my/_partial.erb
). - I'm thinking in removing the
partial
method in favor of one singlerender
method, but I have to think about it a little more since it won't be compatible with older versions (I don't really care about this because I don't know how many people use hobbit-contrib).
If we can move the logic of partial_path
to find_template
in a way that we don't change much, then go for it!
ok I will try it
@patriciomacadden it should look better, I mean this is in one method, but find_template after added partial fix look to much complexity for me.