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 · 1 comment

Comments

Projects
2 participants
@bep
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

This comment has been minimized.

Show comment
Hide comment
@moorereason

moorereason Apr 5, 2017

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)

Contributor

moorereason commented Apr 5, 2017

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 from Consider allowing mixed text/html templates to 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

tplimpl: Allow text partials in HTML templates
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 closed this in #3347 Apr 16, 2017

bep added a commit that referenced this issue Apr 16, 2017

tplimpl: Allow text partials in HTML templates
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

tplimpl: Allow text partials in HTML templates
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

@ghost ghost referenced this issue May 22, 2017

Open

spf13/hugo v0.21 released #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment