Skip to content

Partials should be relative to views, not dirname(path)#112

Closed
blented wants to merge 1 commit intotj:masterfrom
blented:master
Closed

Partials should be relative to views, not dirname(path)#112
blented wants to merge 1 commit intotj:masterfrom
blented:master

Conversation

@blented
Copy link
Copy Markdown

@blented blented commented May 8, 2013

Partials are currently read relative to the dirname of the template
you're rendering, not the views directory. This means that when you're
rendering views/subfolder/page the partials in views/partials won't
load correctly.

Partials are currently read relative to the dirname of the template
you're rendering, not the views directory.  This means that when you're
rendering views/subfolder/page  the partials in views/partials won't
load correctly.
@simov
Copy link
Copy Markdown
Contributor

simov commented May 8, 2013

I personally always render base.html which is at the root i.e. views/base.html. I think something similar was asked in one of the previous issues.
I think if we accept your way someone else may ask to have them relative to the rendered template.

@blented
Copy link
Copy Markdown
Author

blented commented May 8, 2013

Just seems like you set a views folder as the "root" for a reason, so the partials should use that same "root", not be relative to whatever file you're sending.

The trouble comes w/ template inheritance, which I'm doing in Hogan:

views/layouts/default.html

{{$content}}{{/content}}

views/backend/base.html -> extends default
{{<default}}
{{$content}}Site backend{{/content}}
{{/defualt}}

So when I render 'backend/base' with consolidate, the basic layout partials don't load properly because they're relative to 'views/backend' not 'views/'

@simov
Copy link
Copy Markdown
Contributor

simov commented May 8, 2013

Yes I understand your problem, my point was that someone else may expect the partials paths to be relative to the rendered template. The same is true if you want your partials to have absolute paths for some reason.
I think this should be implemented as an option somehow to prevent future inconveniences.

@doowb
Copy link
Copy Markdown
Collaborator

doowb commented Sep 17, 2017

Closing in favor of #86

@doowb doowb closed this Sep 17, 2017
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