diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2010-06-27 22:19:19 +0900 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2010-06-27 22:37:56 +0900 |
commit | 0d15e9501c96d4ee08c91c523f7329135d0f3c5e (patch) | |
tree | 1bd9efbfe1a03ab20d080ef9ceb8c6cbc47d0c88 | |
parent | b49df828fa9faef2a1f093392625408f3708b1f8 (diff) | |
download | erubis-0d15e9501c96d4ee08c91c523f7329135d0f3c5e.tar.gz |
[enhance] support layout template in 'contrib/index.cgi'
-rw-r--r-- | contrib/index.cgi | 6 |
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" \ |