-
-
Save RX14/73fcce2affdf6c8a638a8146e250f43d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ crystal hook.cr | |
<html> | |
<chunk of="html">...</chunk> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ecr" | |
macro content_for(key) | |
__blocks__[{{key}}] = ->() { | |
__kilt_io__ = MemoryIO.new | |
{{ yield }} | |
__kilt_io__.to_s | |
} | |
nil | |
end | |
macro yield_content(key) | |
__blocks__[{{key}}].call | |
end | |
__blocks__ = Hash(Symbol, Proc(String)).new | |
ECR.embed "test.ecr", STDOUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% content_for :some_key do %> | |
<chunk of="html">...</chunk> | |
<% end %> | |
<html> | |
<%= yield_content :some_key %> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment