合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
# `default` The `default` filter returns the passed default value if the value isundefined or empty, otherwise the value of the variable: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 4 5 6 7</pre></div></td><td class="code"><div class="highlight"><pre>{{ var|default('var is not defined') }} {{ var.foo|default('foo item on var is not defined') }} {{ var['foo']|default('foo item on var is not defined') }} {{ ''|default('passed var is empty') }} </pre></div></td></tr></table> When using the `default` filter on an expression that uses variables in somemethod calls, be sure to use the `default` filter whenever a variable can beundefined: <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>{{ var.method(foo|default('foo'))|default('foo') }} </pre></div></td></tr></table> Note Read the documentation for the [*defined*](#) and[*empty*](#) tests to learn more about their semantics. ### Arguments - `default`: The default value