1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-26 22:24:39 +01:00
Commit Graph

354 Commits

Author SHA1 Message Date
Tobias Salzmann
5540947bf1 force explicit type checking 2018-07-31 17:47:45 +02:00
Tobias Salzmann
7ae2fa24ed floor and ceil should return integers 2018-07-25 17:18:10 +02:00
Oliver Steele
e0ae1590bf
Add latest PR to CHANGELOG 2018-06-05 16:36:56 -04:00
Oliver Steele
b8970ec180
Add a CHANGELOG 2018-06-05 16:33:11 -04:00
Oliver Steele
4e0fda9afd
Re-organize README 2018-06-05 16:33:08 -04:00
Oliver Steele
20a3b002f5
Add make pre-commit; lint before testing 2018-06-05 16:33:07 -04:00
Oliver Steele
ca945a04d1
Merge pull request #30 from nsf/master
Properly handle implicit conversion to integer types.
2018-06-05 15:27:13 -04:00
nsf
c32908a4f3 Returning proper error type causes less panics during expression eval.
When user-defined function is called, it does convert all the arguments using
MustConvert, which panics on error with an error. However 'func (e expression)
Evaluate(ctx Context)' from sub package "expressions" catches those panics and
converts some of them to errors. Raw errors returned from strconv functions
are "repanicked", but proper error types such as values.TypeError are not.
Hence we should use it here.
2018-05-31 23:49:25 +05:00
nsf
4354d48a04 Properly handle implicit conversion to integer types.
Go's reflect API is very picky about arguments to Call method. You can't just
pass in the "int" when function expects "int64", even on 64 bit machines. This
patch solves this problem by performing conversions properly. Truncation
problems however, as well as negative to uint issues are completely ignored.
Which is perhaps not ideal, but still better than returning "int" when "int32"
or "int64" is requested.

I did split the Kind switch cases and moved value -> int and value -> float
conversions to separate functions. An alternative to that would be using the
reflection API, which might be less performant. Not that it matters much, but
this solution is correct, even though looks a bit copy & pasty.

Oh and of course all "uint" types were completely missing in the function and
they are now added.
2018-05-31 23:18:57 +05:00
Oliver Steele
aadc886acd Minor formatting fixes in the README 2018-05-30 20:54:10 +00:00
Oliver Steele
d2be34e2e9 Add Contributors section; add nsf as contributor; adopt All Contributors and all-contributors-cli 2018-05-30 20:50:25 +00:00
Oliver Steele
9234f55cd9
Merge pull request #29 from nsf/master
Properly handle variadic functions.
2018-05-30 15:50:03 -04:00
nsf
1a2066b87e Properly handle variadic functions.
This commit addresses two issues:

1. For variadic functions 'convertCallArguments' was allocating exactly
   'len(args)' arguments, which might be less than required, as a result
   zero/default filling loop would panic with out of bounds error.

2. Even if we correctly allocate a proper amount of arguments, zero/default
   filling loop doesn't handle special variadic function type case, when last
   argument has a slice type and reflect API expects plain values as arguments.
   But actually we don't need that, because it's okay to omit variadic values
   altogether, hence the total amount of allocated arguments is
   max(len(args), rt.NumIn()-1).
2018-05-30 19:44:29 +05:00
Oliver Steele
e30a0e2788
Travis: add go 1.10; drop 1.8 2018-03-02 11:41:48 -05:00
Oliver Steele
3811e167ab
Remove errant file 2018-03-02 10:51:28 -05:00
Oliver Steele
8874615b3c Match Ruby string split semantics 2017-09-04 17:51:51 -04:00
Oliver Steele
a02d9e12b4 Follow go style guide re declaring empty slices 2017-09-03 12:13:20 -04:00
Oliver Steele
ba2ecf9542 Add go 1.9 to travis build matrix 2017-08-30 09:38:50 -04:00
Oliver Steele
b6c65ffee6 map[unhashable] returns nil instead of panic 2017-08-23 16:03:46 -04:00
Oliver Steele
a50dc106d2 Convert tests 2017-08-23 15:56:27 -04:00
Oliver Steele
d27c839ae3 variable names 2017-08-23 15:56:18 -04:00
Oliver Steele
1a12f12f1d Convert MapSlice -> map 2017-08-21 15:06:35 -04:00
Oliver Steele
bb24f32cbd list filters operate on MapSlice 2017-08-21 10:30:54 -04:00
Oliver Steele
e1c7224d9c variable names 2017-08-21 09:50:29 -04:00
Oliver Steele
cb6efbf216 join filter: default sep is space; omit nil entries 2017-08-20 11:33:58 -04:00
Oliver Steele
5ebf31a84a Default time format is compatible w/ Liquid 2017-08-18 10:43:31 -04:00
Oliver Steele
804e3d6970 Rearrange tests 2017-08-18 10:35:15 -04:00
Oliver Steele
4bc4c8a71b Define IterationKeyedMap 2017-08-15 18:49:29 -04:00
Oliver Steele
c49d979750 Rename rbstrftime package 2017-08-11 11:55:37 -04:00
Oliver Steele
cdb0e44c6f Move strftime to a separate repo 2017-08-10 19:02:13 -04:00
Oliver Steele
6b15fbf6c7 Tests; implement map[nil] 2017-08-09 08:45:48 -04:00
Oliver Steele
fd4d34c403 Nil pointers are equal, even if different types 2017-08-09 08:42:42 -04:00
Oliver Steele
62f44fa728 Rearrange value methods w/in file 2017-08-09 08:16:36 -04:00
Oliver Steele
9852226d22 Restore m['str'] where m map[interface{}]interface{} 2017-08-08 19:31:33 -04:00
Oliver Steele
e39a1fe0d4 Fix array[nil] 2017-08-08 17:15:29 -04:00
Oliver Steele
51d7166e88 Package docs 2017-08-08 16:42:32 -04:00
Oliver Steele
c50491f609 More drop examples 2017-08-08 16:25:23 -04:00
Oliver Steele
0adf6e7411 README: add Appveyor badge 2017-08-08 16:03:24 -04:00
Oliver Steele
068afefea0 Fix file not found tests for Windows 2017-08-08 15:14:31 -04:00
Oliver Steele
1b3e55a488 Appveyor: remove mingw 2017-08-08 14:54:47 -04:00
Oliver Steele
85bd1ddfe1 Replace extern "C" strftime by go implementation 2017-08-08 14:48:10 -04:00
Oliver Steele
8d53a6b4a8 Remove (commented-out) Strptime and tests 2017-08-05 19:36:18 +02:00
Oliver Steele
4a2c4b4b39 Beefy strftime tests 2017-08-05 19:35:38 +02:00
Oliver Steele
83652f59db Actually cache the drop resolution 2017-08-03 15:20:56 +02:00
Oliver Steele
7f501ce512 Race test, benchmarks, for drop resolution 2017-08-03 15:20:56 +02:00
Oliver Steele
eac67c350b Pull loop renderer into separate method
For more readable profiles
2017-08-03 15:20:56 +02:00
Oliver Steele
519fbbeb04 Merge pull request #28 from Proximaio/feature/struct_pointer_member_fix
Fix struct PropertyValue attempting to use an invalid pointer
2017-08-03 09:20:04 -04:00
James Littlejohn
b2f5f1f9ac Fix struct PropertyValue attempting to use an invalid pointer 2017-08-01 11:27:32 +10:00
Oliver Steele
9866cbf5d7 Race condition 2017-07-27 18:30:03 -04:00
Oliver Steele
fb70314da4 Add forwarders from evaluator pkg 2017-07-27 18:28:16 -04:00