Convert a Text String to a Number in Rust's MiniJinja
This is a test to see about converting incoming text strings to integers that can be used in for
loops in
As of version 2.9.0, trying to convert something other than a number causes the page to fail to render.
I've opened a ticket about that here:
Converting to int halts rendering if the input is not a number
One possible work around is to create a function in the environment and use it to do the conversion. It can send back a none
if the string can't be converted. That would allow a check to happen at the template level that wouldn't prevent the page from rendering.
---
minijinja =
---
use ;
Output:
1
2
invalid operation: invalid float literal (in example:1)
-- end of line --