class Crinja::Tag::With

Overview

The with statement makes it possible to create a new inner scope. Variables set within this scope are not visible outside of the scope.

{% with %}
    {% set foo = 42 %}
    {{ foo }}           # => foo is 42 here
{% endwith %}
{{ foo }}               # => undefined

Because it is common to set variables at the beginning of the scope, you can do that within the with statement. The following two examples are equivalent:

{% with foo = 42 %}
    {{ foo }}
{% endwith %}

{% with %}
    {% set foo = 42 %}
    {{ foo }}
{% endwith %}

See Jinja2 Template Documentation for details.

Defined in:

lib/tag/with.cr

Instance Method Summary

Instance methods inherited from class Crinja::Tag

end_tag : String? end_tag, has_block?(node : TagNode) has_block?, interpret_output(renderer : Renderer, tag_node : TagNode) interpret_output, to_s(io) to_s

Instance Method Detail

def end_tag : String? #

[View source]
def interpret_output(renderer : Crinja::Renderer, tag_node : TagNode) #

[View source]
def name : String #

[View source]