// 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; #[derive(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::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T, css_file_extension: bool) -> io::Result<()> { write!(dst, r##" {title} {css_extension} {favicon} {in_header} {before_content}
{content}
{after_content} {play_js} "##, css_extension = if css_file_extension { format!("", root_path = page.root_path) } else { "".to_owned() }, content = *t, root_path = page.root_path, ty = page.ty, logo = if layout.logo.is_empty() { "".to_string() } else { format!("\ logo", page.root_path, layout.krate, layout.logo) }, title = page.title, description = page.description, keywords = page.keywords, favicon = if layout.favicon.is_empty() { "".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.is_empty() { "".to_string() } else { format!(r#""#, page.root_path) }, ) } pub fn redirect(dst: &mut io::Write, url: &str) -> io::Result<()> { // "##, url = url, ) }