Commit graph

119 commits

Author SHA1 Message Date
Tatsushi Demachi
56534beaf6 Fix sort tpl func to return explicit type value
sort template function returns `[]interface{}` type slice value
regardless of its original element type.

This fixes it to keep the original element type. For example, if it
sorts `map[string]int` type value, it returns `[]int` slice value
instead of `[]interface{}` slice value.
2015-08-07 14:06:06 +02:00
Bjørn Erik Pedersen
c7aa881d90 Fix Unicode issue in Slicestr and Substr
Fixes #1333
2015-08-07 08:52:22 +02:00
Anthony Fok
252ea96d1d Remove deprecated fields and methods for v0.15
Special thanks to @bep for his guidance and
for making sure all of the Hugo themes get updated.

Fixes #1172
2015-07-30 13:33:38 +02:00
Russell Oliver
81e69c416d Add ReadDir function to list local files.
Includes documentation.
2015-07-25 21:56:38 +02:00
Tatsushi Demachi
dd732e84f4 Add nil comparison to where tpl function
`where` template function's internal condition check function always
returns `false` when a target value doesn't exist or it's nil value but
this behavior makes it difficult to filter values which doesn't have a
particular parameter.

To solve it, this adds nil value comparison to the function.
`where Values ".Param.key" nil` like clause can be used for the case
above.

Only "=", "==", "eq", "!=", "<>", "ne" operators are allowed to be used
with `nil`. If an other operator is passed with `nil`, the condition
check function returns `false` like before.

Fix #1232
2015-06-29 19:50:45 +02:00
Ariejan de Vroom
0a2e5424ab Add last template function
`last` allows the user to select the last X items of
and array.
2015-06-15 21:18:38 +02:00
Ariejan de Vroom
627d016cc9 Refactor var name limit to index 2015-06-15 21:18:38 +02:00
Ariejan de Vroom
c335efdd06 Add after template function
Where `first` will return the first N items of a rangeable list,
`after` will return all items after the Nth item.

This allows the user to do something with the first N items and
something different with the remaining items after N.
2015-06-15 21:18:38 +02:00
Tatsushi Demachi
51cabe6faf Fix substr tpl func's int type variant issue
`substr` template function takes one or two range arguments. Both
arguments must be int type values but if it is used with a calclation
function e.g. `add`, `len` etc, it causes a wrong type error.

This fixes the issue to allow the function to take other integer type
variant like `int64` etc.

This also includes a small fix on no range argument case.

Fix #1190
2015-06-06 21:03:30 +02:00
Tatsushi Demachi
601a2ce124 Add time.Time type support to where tpl func
`where` tpl function doesn't support `time.Time` type so if people want
to compare such values, it's required that these values are converted
into `int` and compare them.

This improves it. If `time.Time` values are passed to `where`, it
converts them into `int` internally, compares them and returns the
result.

See also
http://discuss.gohugo.io/t/future-posts-and-past-posts/1229/3
2015-05-26 15:59:36 +02:00
bep
bec839e652 Add relURL template func
Fixes #1126
2015-05-11 13:59:02 +02:00
bep
be0cbeee7f Add absURL template func
Fixes #1106
2015-05-11 12:28:35 +02:00
bep
be6482603e Disable faulty range validation in apply
Fixed #1098
2015-05-02 11:32:28 +02:00
bep
be15927819 tpl: check that types in args match the target func's type
Fixes #1095
2015-05-01 17:00:34 +02:00
bep
be190fdb0d tpl: check for too many arguments in apply
Fixes #1091
2015-04-30 11:41:27 +02:00
bep
be017f187e tpl: check slice bounds in slicestr
Fixes #1090
2015-04-30 11:26:45 +02:00
bep
be3b8a132b tpl: avoid panic on too few args to apply
Fixes #1089
2015-04-30 10:51:10 +02:00
bep
be24457acf Add more options to highlight
Fixes #1021
2015-04-15 20:31:06 +02:00
bep
be2097e1ad tpl: split template.go
The template funcs get their own file. This prevents having to scroll miles to get to the template infrastructure.
2015-04-05 21:03:12 +02:00