class Marten::Template::Tag::Cache


The cache template tag.

The cache template tag allows to cache the content of a template fragment (enclosed within the {% cache %}...{% endcache %} tags) for a specific duration.

At least a cache key and and a cache expiry (expressed in seconds) must be specified when using this tag:

{% cache "mykey" 3600 %}
  Cached content!
{% endcache %}

It should be noted that the cache template tag also supports specifying additional "vary on" arguments that allow to invalidate the cache based on the value of other template variables:

{% cache "mykey" 3600 current_locale %}
  Cached content!
{% endcache %}

Included Modules

Defined in:



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 : 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]