tyler-sommer / stick

A golang port of the Twig templating engine
MIT License
183 stars 36 forks source link

fix merge filter for objects #47

Closed christianWilling closed 3 years ago

christianWilling commented 3 years ago

in the documentation the behavour is to add if its an array and to merge if it's an object https://twig.symfony.com/doc/1.x/filters/merge.html

this should fix this

tyler-sommer commented 3 years ago

Nice catch, @christianWilling! Your changes look good, but would you be up for adding a test or two in filter_test.go? If not, I can see what I can do -- wanted to give you a chance first, if you're willing. Either way, thanks for the PR!

christianWilling commented 3 years ago

im sorry to say that i dont understand how this tests work... maybe you can add one and il take a look into it

tyler-sommer commented 3 years ago

@christianWilling No problem! I've added two tests for the merge filter here: https://github.com/christianWilling/stick/commit/61926e86ca9aeff49e9aef362e713198bbdfc3a1 -- had to add some additional handling to deal with the slice and map results, but maybe that will be useful in the future too.

Thanks very much for taking the time to open this PR!