hobbit-contrib icon indicating copy to clipboard operation
hobbit-contrib copied to clipboard

#4 partial in subfolder

Open wafcio opened this issue 10 years ago • 6 comments

wafcio avatar Jun 30 '14 22:06 wafcio

@houndci: everywhere @patriciomacadden use single quote.

This should fix partial bug in subfolder for render (tilt) and mote.

wafcio avatar Jun 30 '14 22:06 wafcio

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?

patriciomacadden avatar Jun 30 '14 22:06 patriciomacadden

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)?

wafcio avatar Jul 01 '14 07:07 wafcio

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 like path/to/my/_partial), and then in find_template (which gives us views/path/to/my/_partial.erb).
  • I'm thinking in removing the partial method in favor of one single render 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!

patriciomacadden avatar Jul 14 '14 20:07 patriciomacadden

ok I will try it

wafcio avatar Jul 14 '14 20:07 wafcio

@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.

wafcio avatar Jul 14 '14 20:07 wafcio