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

Allow mixed text/html templates #3273

Closed
bep opened this issue Apr 4, 2017 · 2 comments · Fixed by #3347
Closed

Allow mixed text/html templates #3273

bep opened this issue Apr 4, 2017 · 2 comments · Fixed by #3347
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Apr 4, 2017

I lifted this question before, without too much response.

I was reminded by this discussion

https://discuss.gohugo.io/t/hugo-inline-css-optimization-for-google-pagespeed/6032

That the current implementation for custom output types is maybe overly restrictive without any real point.

Right now it is not possible for a HTML template to include a partial that is plain text (defined to be parsed with text/template, i.e. /layouts/index.html => /layouts/partials/mycss.css will not work. Note that /layouts/index.html => /layouts/partials/mycss.html is perfectly fine.

I assume that just allowing the above would be useful, and probably work just fine ... Not sure.

Would love to get feedback (any gotchas? security?) before I spend the work on changing this.

/cc @digitalcraftsman @moorereason

@bep bep self-assigned this Apr 4, 2017
@bep bep added this to the v0.20 milestone Apr 4, 2017
@bep bep added this to In progress in Custom Output Formats Apr 4, 2017
@bep bep moved this from In progress to TODO in Custom Output Formats Apr 4, 2017
@moorereason
Copy link
Contributor

Sounds like a logical step forward. Can't think of any security issues. Gotchas depend on the implementation.

"Shooting From the Hip" proposal: if the name contains a period (.), prepend the lookup order with the explicit name:

Given {{ partial "mycss.css" }}:

  • /layouts/partials/mycss.css
  • /layouts/partials/mycss.css.html
  • /layouts/partials/mycss.css.tmpl

(or whatever the normal lookup order is)

@bep bep modified the milestones: v0.21, v0.20 Apr 6, 2017
@bep bep changed the title Consider allowing mixed text/html templates Allow mixed text/html templates Apr 14, 2017
@bep bep modified the milestones: v0.20.2, v0.21 Apr 14, 2017
@bep bep added the Bug label Apr 14, 2017
bep added a commit to bep/hugo that referenced this issue Apr 15, 2017
Most obvius benefit of this is to include CSS partials with css file suffix into HTML templates.

A valid workaround would be to rename the file `mystyles.html`, but that doesn't work too good for external editors etc.

The css partial is  a method used in some themes before Hugo 0.20, but then it stopped working.

This commit reintroduces that behaviour.

Note that the regular layout lookups for text templates, i.e. "single.json" will be
prefixed with "_text/" on lookup and will only match in the text collection.

Fixes gohugoio#3273
@bep bep closed this as completed in #3347 Apr 16, 2017
bep added a commit that referenced this issue Apr 16, 2017
Most obvius benefit of this is to include CSS partials with css file suffix into HTML templates.

A valid workaround would be to rename the file `mystyles.html`, but that doesn't work too good for external editors etc.

The css partial is  a method used in some themes before Hugo 0.20, but then it stopped working.

This commit reintroduces that behaviour.

Note that the regular layout lookups for text templates, i.e. "single.json" will be
prefixed with "_text/" on lookup and will only match in the text collection.

Fixes #3273
@bep bep moved this from TODO to Merged in Custom Output Formats Apr 16, 2017
bep added a commit that referenced this issue Apr 16, 2017
Most obvius benefit of this is to include CSS partials with css file suffix into HTML templates.

A valid workaround would be to rename the file `mystyles.html`, but that doesn't work too good for external editors etc.

The css partial is  a method used in some themes before Hugo 0.20, but then it stopped working.

This commit reintroduces that behaviour.

Note that the regular layout lookups for text templates, i.e. "single.json" will be
prefixed with "_text/" on lookup and will only match in the text collection.

Fixes #3273
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants