# Additional Filters These filters provide extra utility functions for working with variables in Liquid templates. They help with setting default values, formatting file sizes, rendering placeholder SVGs, and converting values to booleans or numbers. Use these filters to handle edge cases and enhance template flexibility. ## default Sets a default value for any variable with no assigned value. `default` will show its value if the input is either null, false or empty. **Input** ```liquid {% assign test_default = "" %} {{ 'my_string' | default: 'I will not show up' }} {{ test_default | default: "I will show up" }} ``` **Output** ``` my_string I will show up ``` --- ## file_size Formats bytes to prettier file size format. **Input** ```liquid {{ 1024 | file_size }} ``` **Output** ``` 1 KB ``` --- ## placeholder_svg_tag Renders a placeholder SVG. **Input** ```liquid {{ 'image' | placeholder_svg_tag }} ``` **Output** ```html ``` Following options are available: | Target | Size | | ------------------- | ------------------------ | | Category image | `category-`, n=1..7 | | Background | `background-`, n=1..3 | | Product image | `product-`, n=1..12 | | General placeholder | `image` | For more advanced usage, you can define SVG attributes as filter parameters and set a CSS class for the `svg` element. **Input** ```liquid {{ 'product-2' | placeholder_svg_tag: stroke:'blue', width: 20, height: 20, class: 'my-svg-class' }} ``` **Output** ```html ``` --- ## to_bool Converts the input to a boolean value. **Input** ```liquid {{ 'true' | to_bool }} {{ 'false' | to_bool }} {{ '1' | to_bool }} {{ '0' | to_bool }} {{ 'yes' | to_bool }} {{ 'no' | to_bool }} {{ 'on' | to_bool }} {{ 'off' | to_bool }} ``` **Output** ``` true false true false true false true false ``` --- ## to_number Converts the input to a number. **Input** ```liquid {{ '123' | to_number }} {{ '123.45' | to_number }} {{ '123.45.67' | to_number }} ``` **Output** ``` 123 123.45 123.45 ```