Add render macro to kemal core to have dynamic rendering mechanism. It actually binds built-in ecr parser to the Kemal as a macro.

This commit is contained in:
Fatih Kadir Akın 2015-12-06 16:05:16 +02:00
parent 692939dfe8
commit 945fa59a6c
6 changed files with 73 additions and 1 deletions

14
src/kemal/view.cr Normal file
View file

@ -0,0 +1,14 @@
# Kemal render uses built-in ECR to render methods.
## Usage
# get '/' do
# render 'hello.ecr'
# end
require "ecr/macros"
macro render(filename)
String.build do |__view__|
embed_ecr {{filename}}, "__view__"
end
end