class Crinja::Tag::Set

Overview

Inside code blocks, you can also assign values to variables. Assignments at top level (outside of blocks, macros or loops) are exported from the template like top level macros and can be imported by other templates.

Assignments use the set tag and can have multiple targets:

{% set navigation = [('index.html', 'Index'), ('about.html', 'About')] %}
{% set key, value = call_something() %}

It is also possible to use block assignments to capture the contents of a set block into a variable name. Instead of using an equals sign and a value, you just write the variable name and then everything until {% endset %} is captured.

{% set navigation %}

  • Index
  • Downloads {% endset %}

    
    See [Jinja2 Template Documentation](http://jinja.pocoo.org/docs/2.9/templates/#assignments) for details.

    Defined in:

    lib/tag/set.cr

    Instance Method Summary

    Instance Method Detail

    def end_tag : String? #

    [View source]
    def has_block?(node : TagNode) #

    [View source]
    def name : String #

    [View source]