[−][src]Function bloguen::ops::format_output
pub fn format_output<W, E, Tz, St, Sc>(
to_format: &str,
blog_name: &str,
language: &LanguageTag,
additional_data_sets: &[&BTreeMap<String, String>],
raw_post_name: &str,
normalised_post_name: &str,
number: usize,
title: &str,
author: &str,
post_date: &DateTime<Tz>,
tags: &[&[TagName]],
styles: &[&[St]],
scripts: &[&[Sc]],
into: &mut W,
out_name_err: E
) -> Result<Cow<'static, str>, Error> where
W: Write,
E: Into<Cow<'static, str>>,
Tz: TimeZone,
St: WrappedElement,
Sc: WrappedElement,
Fill out an HTML template.
All fields must be addressed even if formatted to be empty.
Examples
let head = r###" <!-- nabijaczleweli.xyz (c) by nabijaczleweli@gmail.com (nabijaczleweli) nabijaczleweli.xyz is licensed under a Creative Commons Attribution 4.0 International License. You should have received a copy of the license along with this work. If not, see <https://creativecommons.org/licenses/by/4.0/>. --> <!-- RSS_PUB_DATE: "{date(post, rfc_2822)}" --> <!DOCTYPE html> <html lang="{language}"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="author" content="{author}"> <meta name="description" content="{data-desc}"> <title>{title}</title> {styles} {scripts} </head> <body> {tags} {tags()} {tags(пост-таг)} {pass_paragraphs(2, data-insertable)} "###; let global_data = vec![].into_iter().collect(); let local_data = vec![("desc".to_string(), "Każdy koniec to nowy początek [PL]".to_string()), ("insertable".to_string(), "<p>Hi!</p>\n<p>My name is…</p>\n<p>What?</p>\n".to_string())].into_iter().collect(); let mut out = vec![]; let res = format_output( head, "Блогг", &LANGUAGE_EN_GB, &[&global_data, &local_data], "003. 2018-02-05 release-front - a generic release front-end, like Patchwork's", "003. 2018-02-05 12-33-05 release-front - a generic release front-end, like Patchwork's", 3, "release-front - a generic release front-end, like Patchwork's", "nabijaczleweli", &DateTime::parse_from_rfc3339("2018-09-06T18:32:22+02:00").unwrap(), &[&["vodka".parse().unwrap(), "depression".parse().unwrap()][..], &["коммунизм".parse().unwrap()][..]], &[&[StyleElement::from_link("//nabijaczleweli.xyz/kaschism/assets/column.css")], &[StyleElement::from_literal(".indented { text-indent: 1em; }")]], &[&[ScriptElement::from_link("/content/assets/syllable.js")], &[ScriptElement::from_literal("alert(\"You're the 1`000`000th visitor!\");")]], &mut out, "test blog"); assert_eq!(res, Ok("test blog".into())); assert_eq!(String::from_utf8(out).unwrap(), r###" <!-- nabijaczleweli.xyz (c) by nabijaczleweli@gmail.com (nabijaczleweli) nabijaczleweli.xyz is licensed under a Creative Commons Attribution 4.0 International License. You should have received a copy of the license along with this work. If not, see <https://creativecommons.org/licenses/by/4.0/>. --> <!-- RSS_PUB_DATE: "Thu, 6 Sep 2018 18:32:22 +0200" --> <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="author" content="nabijaczleweli"> <meta name="description" content="Każdy koniec to nowy początek [PL]"> <title>release-front - a generic release front-end, like Patchwork's</title> <link href="//nabijaczleweli.xyz/kaschism/assets/column.css" rel="stylesheet" /> <style type="text/css"> .indented { text-indent: 1em; } </style> <script type="text/javascript" src="/content/assets/syllable.js"></script> <script type="text/javascript"> alert("You're the 1`000`000th visitor!"); </script> </head> <body> <span class="post-tag">vodka</span> <span class="post-tag">depression</span> <span class="post-tag">коммунизм</span> <span class="post-tag">vodka</span> <span class="post-tag">depression</span> <span class="post-tag">коммунизм</span> <span class="пост-таг">vodka</span> <span class="пост-таг">depression</span> <span class="пост-таг">коммунизм</span> <p>Hi!</p> <p>My name is…</p> "###);