// 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; use externalfiles::ExternalHtml; #[deriving(Clone)] pub struct Layout { pub logo: String, pub favicon: String, pub external_html: ExternalHtml, pub krate: String, pub playground_url: String, } pub struct Page<'a> { pub title: &'a str, pub ty: &'a str, pub root_path: &'a str, pub description: &'a str, pub keywords: &'a str } pub fn render( dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T) -> io::IoResult<()> { write!(dst, r##" {title} {favicon} {in_header} {before_content}
{content}
{after_content} {play_js} "##, content = *t, root_path = page.root_path, ty = page.ty, logo = if layout.logo.len() == 0 { "".to_string() } else { format!("\ ", page.root_path, layout.krate, layout.logo) }, title = page.title, description = page.description, keywords = page.keywords, favicon = if layout.favicon.len() == 0 { "".to_string() } else { format!(r#""#, layout.favicon) }, in_header = layout.external_html.in_header, before_content = layout.external_html.before_content, after_content = layout.external_html.after_content, sidebar = *sidebar, krate = layout.krate, play_url = layout.playground_url, play_js = if layout.playground_url.len() == 0 { "".to_string() } else { format!(r#""#, page.root_path) }, ) } pub fn redirect(dst: &mut io::Writer, url: &str) -> io::IoResult<()> { write!(dst, r##" "##, url = url, ) }