mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Make macro variables local
This commit is contained in:
parent
fb5ac9e0b6
commit
dee1d1c58b
1 changed files with 4 additions and 4 deletions
|
@ -32,21 +32,21 @@ CONTENT_FOR_BLOCKS = Hash(String, Tuple(String, Proc(String))).new
|
||||||
# layout, inside the <head> tag, and each view can call <tt>content_for</tt>
|
# layout, inside the <head> tag, and each view can call <tt>content_for</tt>
|
||||||
# setting the appropriate set of tags that should be added to the layout.
|
# setting the appropriate set of tags that should be added to the layout.
|
||||||
macro content_for(key, file = __FILE__)
|
macro content_for(key, file = __FILE__)
|
||||||
proc = ->() {
|
%proc = ->() {
|
||||||
__kilt_io__ = MemoryIO.new
|
__kilt_io__ = MemoryIO.new
|
||||||
{{ yield }}
|
{{ yield }}
|
||||||
__kilt_io__.to_s
|
__kilt_io__.to_s
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, proc
|
CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, %proc
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
macro yield_content(key)
|
macro yield_content(key)
|
||||||
if CONTENT_FOR_BLOCKS.has_key?({{key}})
|
if CONTENT_FOR_BLOCKS.has_key?({{key}})
|
||||||
__caller_filename__ = CONTENT_FOR_BLOCKS[{{key}}][0]
|
__caller_filename__ = CONTENT_FOR_BLOCKS[{{key}}][0]
|
||||||
proc = CONTENT_FOR_BLOCKS[{{key}}][1]
|
%proc = CONTENT_FOR_BLOCKS[{{key}}][1]
|
||||||
proc.call if __content_filename__ == __caller_filename__
|
%proc.call if __content_filename__ == __caller_filename__
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue