Move macros from view to macros

This commit is contained in:
Sdogruyol 2015-12-14 20:05:46 +02:00
parent 5c97942707
commit 66c8b6d857
2 changed files with 18 additions and 18 deletions

View file

@ -1,3 +1,21 @@
require "ecr/macros"
# Uses built-in ECR to render views.
# # Usage
# get '/' do
# render 'hello.ecr'
# end
macro render(filename)
String.build do |__view__|
embed_ecr({{filename}}, "__view__")
end
end
macro render(filename, layout)
content = render {{filename}}
render {{layout}}
end
macro redirect(url)
env.response.headers.add "Location", {{url}}
env.response.status_code = 301

View file

@ -1,21 +1,3 @@
require "ecr/macros"
# Uses built-in ECR to render views.
# # Usage
# get '/' do
# render 'hello.ecr'
# end
macro render(filename)
String.build do |__view__|
embed_ecr({{filename}}, "__view__")
end
end
macro render(filename, layout)
content = render {{filename}}
render {{layout}}
end
# Template for 404 Not Found
def render_404
template = <<-HTML