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

custom output formats: Handle both text and HTML templates #3221

Closed
1 of 2 tasks
bep opened this issue Mar 23, 2017 · 1 comment · Fixed by #3243 or #3261
Closed
1 of 2 tasks

custom output formats: Handle both text and HTML templates #3221

bep opened this issue Mar 23, 2017 · 1 comment · Fixed by #3243 or #3261
Assignees
Labels
Milestone

Comments

@bep
Copy link
Member

bep commented Mar 23, 2017

Split out of #2828

  • Regular templates
  • Partials ...?
@bep bep added this to the v0.20 milestone Mar 23, 2017
@bep bep self-assigned this Mar 23, 2017
@bep bep changed the title custom output types: Handle both text and HTML templates custom output formats: Handle both text and HTML templates Mar 23, 2017
@bep bep mentioned this issue Mar 23, 2017
26 tasks
@bep bep added this to TODO in Custom Output Formats Mar 24, 2017
@bep bep moved this from TODO to In progress in Custom Output Formats Mar 30, 2017
@bep bep moved this from In progress to Developed in Custom Output Formats Apr 1, 2017
bep added a commit to bep/hugo that referenced this issue Apr 1, 2017
Before this commit, Hugo used `html/template` for all Go templates.

While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.

This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.

A couple of notes:

* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.

Fixes gohugoio#3221
@bep bep closed this as completed in #3243 Apr 2, 2017
bep added a commit that referenced this issue Apr 2, 2017
Before this commit, Hugo used `html/template` for all Go templates.

While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.

This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.

A couple of notes:

* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.

Fixes #3221
bep added a commit to bep/hugo that referenced this issue Apr 2, 2017
Before this commit, Hugo used `html/template` for all Go templates.

While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.

This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.

A couple of notes:

* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.

Fixes gohugoio#3221
bep added a commit that referenced this issue Apr 2, 2017
Before this commit, Hugo used `html/template` for all Go templates.

While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc.

This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use.

A couple of notes:

* The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work.
* Ambiguous types will fall back to HTML.
* Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials.
* Shortcode templates are, by definition, currently HTML templates only.

Fixes #3221
@bep bep moved this from Developed to Merged in Custom Output Formats Apr 2, 2017
@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 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
1 participant