Commit graph

7 commits

Author SHA1 Message Date
Tatsushi Demachi
d12f6cd775 Fix echoParam template function to accept string key name
This changes `echoParam` template function behavior to accept not only
an array or a slice and its index pair but also a map and its key pair.

This also changes the function that float and uint values are treated as
a valid result type of it.

Fix #771
2015-01-08 02:32:17 +01:00
Tatsushi Demachi
0d17ee7ed4 Add operator argument to where template function
It allows to use `where` template function like SQL `where` clause.
For example,

    {{ range where .Data.Pages "Type" "!=" "post" }}
        {{ .Content }}
    {{ end }}

Now these operators are implemented:

    =, ==, eq, !=, <>, ne, >=, ge, >, gt, <=, le, <, lt, in, not in

It also fixes `TestWhere` more readable
2015-01-04 12:15:17 +01:00
Tatsushi Demachi
975f4cf126 Refactor tpl codes
- Use indirect function instead of the same code copies
- Fix missing arguments of some test codes
2014-12-29 15:47:50 +01:00
Tatsushi Demachi
fa8ac87d5e Make 'where' template function accepts dot chaining key argument
'where' template function used to accept only each element's struct
field name, method name and map key name as its second argument. This
extends it to accept dot chaining key like 'Params.foo.bar' as the
argument. It evaluates sub elements of each array elements and checks it
matches the third argument value.

Typical use case would be for filtering Pages by user defined front
matter value. For example, to filter pages which have 'Params.foo.bar'
and its value is 'baz', it is used like

    {{ range where .Data.Pages "Params.foo.bar" "baz" }}
        {{ .Content }}
    {{ end }}

It ignores all leading and trailing dots so it can also be used with
".Params.foo.bar"
2014-12-29 12:53:41 +01:00
Derek Perkins
717f702e2f Added delimit & sort template functions, tests and docs 2014-12-18 22:28:12 -05:00
bep
53c707bb1d Add markdownify template filter
Note that this is a Markdownify filter, and is named as such; it's not a Asccidoc filter or in any way connected to a Page.

Fixes #524
2014-11-24 23:17:25 -05:00
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
Renamed from hugolib/template_test.go (Browse further)