-
-
Save trapped/127cb61d13ffc29005c5 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
<html> | |
<head> | |
<title><%= page_title %></title> | |
<link rel="stylesheet" type="text/css" href="/bootstrap.css"> | |
</head> | |
<body> | |
<%= partial_body %> | |
</body> | |
</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
class HeaderView < View | |
def initialize(response : Http::Response) | |
@controller = self | |
@response = response | |
@partial_body = response.body | |
@page_title = "" | |
end | |
ecr_file "#{__DIR__}/views/header.ecr" | |
def render | |
new_body = StringIO.new | |
to_s(new_body) | |
new_body.to_s | |
end | |
end |
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
class HeaderMiddleware < Middleware::Base | |
def call(request) | |
response = @app.call(request) | |
response.body = HeaderView.new(response).render | |
response | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment