Commit graph

21 commits

Author SHA1 Message Date
spf13
73f203ad86 Move template library into it's own package (tpl). No longer dependent on hugolib. Can be used externally. 2014-11-20 12:36:57 -05:00
bep
55fcd2f30f Shortcode rewrite, take 2
This commit contains a restructuring and partial rewrite of the shortcode handling.

Prior to this commit rendering of the page content was mingled with handling of the shortcodes. This led to several oddities.

The new flow is:

1. Shortcodes are extracted from page and replaced with placeholders.
2. Shortcodes are processed and rendered
3. Page is processed
4. The placeholders are replaced with the rendered shortcodes

The handling of summaries is also made simpler by this.

This commit also introduces some other chenges:

1. distinction between shortcodes that need further processing and those who do not:

* `{{< >}}`: Typically raw HTML. Will not be processed.
* `{{% %}}`: Will be processed by the page's markup engine (Markdown or (infuture) Asciidoctor)

The above also involves a new shortcode-parser, with lexical scanning inspired by Rob Pike's talk called "Lexical Scanning in Go",
which should be easier to understand, give better error messages and perform better.

2. If you want to exclude a shortcode from being processed (for documentation etc.), the inner part of the shorcode must be commented out, i.e. `{{%/* movie 47238zzb */%}}`. See the updated shortcode section in the documentation for further examples.

The new parser supports nested shortcodes. This isn't new, but has two related design choices worth mentioning:

* The shortcodes will be rendered individually, so If both `{{< >}}` and `{{% %}}` are used in the nested hierarchy, one will be passed through the page's markdown processor, the other not.
* To avoid potential costly overhead of always looking far ahead for a possible closing tag, this implementation looks at the template itself, and is branded as a container with inner content if it contains a reference to `.Inner`

Fixes #565
Fixes #480
Fixes #461

And probably some others.
2014-11-17 18:32:06 -05:00
bep
8ad9c0a7dd Make Where template-method accept methodname as key
This is necessary to make constructs like `{{ range first 1 (where .Data.Pages "Type" "post") }}` -- as Type and Section is methods not fields.
2014-11-13 12:42:26 -05:00
Austin Ziegler
d7e6e490c2 Allow partial without .html
`partial "header" .` means the same thing as `partial "header.html" .`.
2014-11-13 12:30:45 -05:00
Tatsushi Demachi
af47e5a2cf Extend template's mod and modBool functions to accept any int types
Fixes #575
2014-11-01 23:00:46 -04:00
bep
da5d98e958 Make First accept any int
TOML and YAML handles integers differently, creating issues when using integer values from configuration or front matter in the First template function.

This currently works in YAML (parses into int), but not in TOML (parses into int64).

This commit modifies First so it accepts any int.

Fixes #551
2014-10-15 12:39:09 -04:00
bep
16330cea91 Add nil-check to Intersect
The Intersect template-method would fail if one or both of the lists were nil (post vs page; post has tags, page has not).

This commit adds a nil-check and returns an empty result if any of the inputs are nil.

See #537
2014-10-15 12:31:22 -04:00
Will Stevens
938733f48f added In and Intersect template functions 2014-10-07 16:52:12 -04:00
spf13
e3d4d40d32 better error messages for template errors 2014-10-02 13:37:38 -04:00
Tatsushi Demachi
5d565c34e5 Extend template's basic math functions to accept float, uint and string values 2014-09-22 09:01:40 -04:00
Joel Scoble
becd4fe337 refactor handling of amber to AddTemplateFile as the TODO note stated. Used switch statement to make it easier to add other template support 2014-09-11 17:09:16 -04:00
spf13
1b7f18e391 Making partials context optional for compatibility with template.
If not provided, context is nil.
2014-09-03 11:30:08 -04:00
Tatsushi Demachi
002a5b6756 Add 'where' template function 2014-08-18 11:31:17 -04:00
spf13
c297d7451f Adding 'partial' template function to add theme / local awareness to the partials directory. 2014-06-06 16:15:19 -04:00
Vincent Batoufflet
73cbefdbc8 Make template comparison functions handle floats 2014-05-10 15:38:18 -04:00
Vincent Batoufflet
179225449c Add template comparison functions (Go 1.1 compat) 2014-05-09 22:42:28 -04:00
spf13
4a8de8ea46 Add Disqus support out of the box. Move template/bundle into hugolib. 2014-04-23 02:53:12 -04:00
Noah Campbell
79d9f82e79 Code reorg, helpers.go has been decomposed.
It started with wanting to move templates in template bundles and the
rest followed.  I did my best to start grouping related functions
together, but there are some that I missed.  There is also the method
Urlize that seems to be a special function used in both worlds.  I'll
need to revisit this method.
2013-09-03 16:16:07 -07:00
Noah Campbell
3ecc698f5e Remove hugolib.HTML and hugolib.URL types
These types were not be rendered correctly by the html/template package.
Removing them gets the correct behavior.

Fixes #74
2013-09-03 12:43:56 -07:00
Fabrizio (Misto) Milo
ba82a20321 Add support for amber files
If a layout file ends with .amber it will interpreted as a Amber file

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:32 -07:00
Fabrizio (Misto) Milo
ee5865f239 Abstract html/template dependency
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:27 -07:00