ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# `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