Commit graph

7 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 5c5efa03d2 tpl: Rework to handle both text and HTML templates
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
2017-04-02 11:37:30 +02:00
Bjørn Erik Pedersen 2bea9d0ca1 Revert "tplimpl: return an error on unsupported type in isSet"
This breaks the theme site and lots of themes, so we will have to thinkg a little harder about this one.

This reverts commit 74ea81b885.
2017-03-26 20:09:08 +02:00
digitalcraftsman 5d0748ce51 tpl: Add union template func 2017-03-12 23:04:12 +01:00
Cameron Moore 45b9d7223a tplimpl: Add built-in print funcs to FuncMap
Add print, printf, and println to the Hugo FuncMap so that they are
accessible to the apply template func.

Updates #3139
2017-03-09 00:21:55 +01:00
Cameron Moore 74ea81b885 tplimpl: return an error on unsupported type in isSet
Fixes #3092
2017-03-02 00:11:10 +01:00
Bjørn Erik Pedersen 77cbe4d60b tplimpl: Refactor imageConfig into a struct
Updates #2701
2017-02-17 17:15:26 +01:00
Bjørn Erik Pedersen c507e2717d tpl: Refactor package
Now:

* The template API lives in /tpl
* The rest lives in /tpl/tplimpl

This is bound te be more improved in the future.

Updates #2701
2017-02-17 17:15:26 +01:00
Renamed from tpl/template_funcs.go (Browse further)