// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::fmt; use std::io; #[deriving(Clone)] pub struct Layout { pub logo: String, pub favicon: String, pub krate: String, } pub struct Page<'a> { pub title: &'a str, pub ty: &'a str, pub root_path: &'a str, } pub fn render( dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T) -> io::IoResult<()> { write!(dst, r##" {title} {favicon, select, none{} other{}}
{content}
"##, content = *t, root_path = page.root_path, ty = page.ty, logo = nonestr(layout.logo.as_slice()), title = page.title, favicon = nonestr(layout.favicon.as_slice()), sidebar = *sidebar, krate = layout.krate, ) } fn nonestr<'a>(s: &'a str) -> &'a str { if s == "" { "none" } else { s } }