Make macro variables local

This commit is contained in:
sdogruyol 2016-07-13 16:24:25 +03:00
parent fb5ac9e0b6
commit dee1d1c58b
1 changed files with 4 additions and 4 deletions

View File

@ -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>
# setting the appropriate set of tags that should be added to the layout.
macro content_for(key, file = __FILE__)
proc = ->() {
%proc = ->() {
__kilt_io__ = MemoryIO.new
{{ yield }}
__kilt_io__.to_s
}
CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, proc
CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, %proc
nil
end
macro yield_content(key)
if CONTENT_FOR_BLOCKS.has_key?({{key}})
__caller_filename__ = CONTENT_FOR_BLOCKS[{{key}}][0]
proc = CONTENT_FOR_BLOCKS[{{key}}][1]
proc.call if __content_filename__ == __caller_filename__
%proc = CONTENT_FOR_BLOCKS[{{key}}][1]
%proc.call if __content_filename__ == __caller_filename__
end
end