class Marten::Template::Tag::For

Overview

The for template tag.

The for template tag allows to loop over the items of iterable objects. It supports unpacking multiple items when applicable (eg. when iterating over hashes) and also handles fallbacks through the use of the else inner block:

{% for item in items %}
  Display {{ item }}
{% else %}
  No items!
{% endfor %}

Included Modules

Defined in:

marten/template/tag/for.cr
marten/template/tag/for/loop.cr

Constructors

Instance Method Summary

Instance methods inherited from module Marten::Template::Tag::CanSplitSmartly

split_smartly(expression : String) : Array(String) split_smartly

Instance methods inherited from class Marten::Template::Tag::Base

render(context : Context) : String render

Constructor methods inherited from class Marten::Template::Tag::Base

new(parser : Parser, source : String) new

Constructor Detail

def self.new(parser : Parser, source : String) #

[View source]

Instance Method Detail

def render(context : Context) : String #
Description copied from class Marten::Template::Tag::Base

Render the template tag for a given context.


[View source]