pub fn pack(target_dir: String, contents: String) {
    let target_path = std::path::Path::new(&target_dir);

    for item in Asset::iter() {
        let item = item.as_ref();
        let s = Asset::get(item).unwrap();

        let item = if item == "template.html" {
            "index.html"
        } else {
            item
        };
        let pb = target_path.join(&item);
        let path = pb.as_path();
        if let Some(dir) = path.parent() {
            if !dir.is_dir() {
                info!("creating dir: {}", dir.to_str().unwrap());
                std::fs::create_dir_all(&dir).unwrap();
            }
            assert!(dir.is_dir());
        }

        let f = std::fs::File::create(&path).unwrap();
        let mut bf = std::io::BufWriter::new(f);

        if item == "index.html" {
            let s = String::from_utf8(s.to_vec()).unwrap();
            let lines = s.lines();
            for l in lines {
                if l == "<!-- content -->" {
                    bf.write_all(contents.as_bytes()).unwrap();
                } else {
                    bf.write_all(l.as_bytes()).unwrap();
                }
                bf.write_all("\n".as_bytes()).unwrap();
            }
        } else {
            bf.write_all(s.as_ref()).unwrap();
        }
        bf.flush().unwrap();
    }
}
/// output complete html contents into target_dir
output complete html contents into target_dir
output complete html contents into target_dir
pub fn pack(target_dir: String, contents: String) {
    let target_path = std::path::Path::new(&target_dir);
    for item in Asset::iter() {
        let item = item.as_ref();
        let s = Asset::get(item).unwrap();
        let item = if item == "template.html" {
            "index.html"
        } else {
            item
        };
        let pb = target_path.join(&item);
        let path = pb.as_path();
        if let Some(dir) = path.parent() {
            if !dir.is_dir() {
                info!("creating dir: {}", dir.to_str().unwrap());
                std::fs::create_dir_all(&dir).unwrap();
            }
            assert!(dir.is_dir());
        }
        let f = std::fs::File::create(&path).unwrap();
        let mut bf = std::io::BufWriter::new(f);
        if item == "index.html" {
            let s = String::from_utf8(s.to_vec()).unwrap();
            let lines = s.lines();
            for l in lines {
                if l == "<!-- content -->" {
                    bf.write_all(contents.as_bytes()).unwrap();
                } else {
                    bf.write_all(l.as_bytes()).unwrap();
                }
                bf.write_all("\n".as_bytes()).unwrap();
            }
        } else {
            bf.write_all(s.as_ref()).unwrap();
        }
        bf.flush().unwrap();
    }
}
pub fn pack ( target_dir : String , contents : String ) { let target_path = std :: path :: Path :: new ( & target_dir ) ; for item in Asset :: iter ( ) { let item = item . as_ref ( ) ; let s = Asset :: get ( item ) . unwrap ( ) ; let item = if item == " " { " " } else { item } ; let pb = target_path . join ( & item ) ; let path = pb . as_path ( ) ; if let Some ( dir ) = path . parent ( ) { if ! dir . is_dir ( ) { info ! ( " " dir to_str ( ) unwrap ( ) ) ; std :: fs :: create_dir_all ( & dir ) . unwrap ( ) ; } assert ! ( dir is_dir ( ) ) ; } let f = std :: fs :: File :: create ( & path ) . unwrap ( ) ; let mut bf = std :: io :: BufWriter :: new ( f ) ; if item == " " { let s = String :: from_utf8 ( s . to_vec ( ) ) . unwrap ( ) ; let lines = s . lines ( ) ; for l in lines { if l == " " { bf . write_all ( contents . as_bytes ( ) ) . unwrap ( ) ; } else { bf . write_all ( l . as_bytes ( ) ) . unwrap ( ) ; } bf . write_all ( " \n " . as_bytes ( ) ) . unwrap ( ) ; } } else { bf . write_all ( s . as_ref ( ) ) . unwrap ( ) ; } bf . flush ( ) . unwrap ( ) ; } }
output complete html contents into target_dir
output complete html contents into target_dir
target_dir
String
contents
String