summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2010-06-27 22:19:19 +0900
committermakoto kuwata <kwa@kuwata-lab.com>2010-06-27 22:37:56 +0900
commit0d15e9501c96d4ee08c91c523f7329135d0f3c5e (patch)
tree1bd9efbfe1a03ab20d080ef9ceb8c6cbc47d0c88
parentb49df828fa9faef2a1f093392625408f3708b1f8 (diff)
downloaderubis-0d15e9501c96d4ee08c91c523f7329135d0f3c5e.tar.gz
[enhance] support layout template in 'contrib/index.cgi'
-rw-r--r--contrib/index.cgi6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/index.cgi b/contrib/index.cgi
index d740e4e..6e948fb 100644
--- a/contrib/index.cgi
+++ b/contrib/index.cgi
@@ -11,6 +11,7 @@ include Erubis::XmlHelper
ERUBY = Erubis::Eruby # or Erubis::EscapeEruby
@encoding = nil
+@layout = '_layout.rhtml'
## helper class to represent http error
class HttpError < Exception
@@ -40,6 +41,11 @@ begin
## process as eRuby file
eruby = ERUBY.load_file(filepath) # or ERUBY.new(File.read(filepath))
html = eruby.result()
+ ## use layout template
+ if @layout && File.file?(@layout)
+ @content = html
+ html = ERUBY.load_file(@layout).result()
+ end
## send response
print @encoding \
? "Content-Type: text/html; charset=#{@encoding}\r\n" \