Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4 partial in subfolder #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wafcio
Copy link

@wafcio wafcio commented Jun 30, 2014

No description provided.

@@ -16,8 +16,14 @@ def layouts_path
"#{views_path}/layouts"
end

def partial_path(template)
parts = template.split('/')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@wafcio
Copy link
Author

wafcio commented Jun 30, 2014

@houndci: everywhere @patriciomacadden use single quote.

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

@patriciomacadden
Copy link
Owner

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?

@wafcio
Copy link
Author

wafcio commented Jul 1, 2014

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

@patriciomacadden
Copy link
Owner

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!

@wafcio
Copy link
Author

wafcio commented Jul 14, 2014

ok I will try it

@@ -9,6 +9,9 @@ def default_layout
end

def find_template(template)
if template.to_s[0] == '_' && template.match('/')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@wafcio
Copy link
Author

wafcio commented Jul 14, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants