summaryrefslogtreecommitdiffstats
path: root/src/ext/kemal_content_for.cr
blob: a4f3fd96bff397d84c177484e801f1f9fe202058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Overrides for Kemal's `content_for` macro in order to keep using
# kilt as it was before Kemal v1.1.1 (Kemal PR #618).

require "kemal"
require "kilt"

macro content_for(key, file = __FILE__)
  %proc = ->() {
    __kilt_io__ = IO::Memory.new
    {{ yield }}
    __kilt_io__.to_s
  }

  CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, %proc
  nil
end