Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make #each handle non-iterable values like the original JS library.
Previously things like `{{#each "foo"}}` were render errors. Now non-iterable values are treated like empty iterables. This brings handlebars-rust's behavior closer in line with the original JavaScript library. Here are the two new test cases in the handlebars playground: 1. https://handlebarsjs.com/playground.html#format=1¤tExample=%7B%22template%22%3A%22%7B%7B%23each%20this%7D%7Deach%20block%7B%7Belse%7D%7Delse%20block%7B%7B%2Feach%7D%7D%22%2C%22partials%22%3A%5B%5D%2C%22input%22%3A%22%5C%22strings%20aren't%20iterable%5C%22%22%2C%22output%22%3A%22else%20block%22%2C%22preparationScript%22%3A%22%22%2C%22handlebarsVersion%22%3A%224.7.6%22%7D 2. https://handlebarsjs.com/playground.html#format=1¤tExample=%7B%22template%22%3A%22%7B%7B%23*inline%20%5C%22walk%5C%22%7D%7D(%7B%7B%23each%20this%7D%7D%7B%7B%23if%20%40key%7D%7D%7B%7B%40key%7D%7D%7B%7Belse%7D%7D%7B%7B%40index%7D%7D%7B%7B%2Fif%7D%7D%3A%20%7B%7Bthis%7D%7D%20%7B%7B%3E%20walk%20this%7D%7D%2C%20%7B%7B%2Feach%7D%7D)%7B%7B%2Finline%7D%7D%5Cn%7B%7B%3E%20walk%7D%7D%22%2C%22partials%22%3A%5B%5D%2C%22input%22%3A%22%7B%5Cn%20%20%20%20%5C%22array%5C%22%3A%20%5B42%2C%20%7B%5C%22wow%5C%22%3A%20%5C%22cool%5C%22%7D%2C%20%5B%5B%5D%5D%5D%2C%5Cn%20%20%20%20%5C%22object%5C%22%3A%20%7B%20%5C%22a%5C%22%3A%20%7B%20%5C%22b%5C%22%3A%20%5C%22c%5C%22%2C%20%5C%22d%5C%22%3A%20%5B%5C%22e%5C%22%5D%20%7D%20%7D%2C%5Cn%20%20%20%20%5C%22string%5C%22%3A%20%5C%22hi%5C%22%5Cn%7D%22%2C%22output%22%3A%22%5Cn(array%3A%2042%2C%5Bobject%20Object%5D%2C%20(0%3A%2042%20()%2C%201%3A%20%5Bobject%20Object%5D%20(wow%3A%20cool%20()%2C%20)%2C%202%3A%20%20(0%3A%20%20()%2C%20)%2C%20)%2C%20object%3A%20%5Bobject%20Object%5D%20(a%3A%20%5Bobject%20Object%5D%20(b%3A%20c%20()%2C%20d%3A%20e%20(0%3A%20e%20()%2C%20)%2C%20)%2C%20)%2C%20string%3A%20hi%20()%2C%20)%22%2C%22preparationScript%22%3A%22%22%2C%22handlebarsVersion%22%3A%224.7.6%22%7D
- Loading branch information