/// Builds a template, writing static data as appropriate. This should be used as part of a larger build process. This returns both a list
/// of the extracted render options for this template (needed at request time), a list of pages that it explicitly generated, and a boolean
/// as to whether or not it only generated a single page to occupy the template's root path (`true` unless using using build-time path
/// generation).
Builds a template, writing static data as appropriate. This should be used as part of a larger build process. This returns both a list
of the extracted render options for this template (needed at request time), a list of pages that it explicitly generated, and a boolean
as to whether or not it only generated a single page to occupy the template's root path (`true` unless using using build-time path
generation).
Builds a template writing static data as appropriate . This should be used as part of a larger build process . This returns both a list of the extracted render options for this template ( needed at request time ) a list of pages that it explicitly generated and a boolean as to whether or not it only generated a single page to occupy the template ' s root path ( ` true ` unless using using build - time path generation ) .
pub async fn build_template(
    template: &Template<SsrNode>,
    translator: &Translator,
    (immutable_store, mutable_store): (&ImmutableStore, &impl MutableStore),
    exporting: bool,
) -> Result<(Vec<String>, bool), ServerError> {
    let mut single_page = false;
    let template_path = template.get_path();
    // If we're exporting, ensure that all the template's strategies are export-safe (not requiring a server)
    if exporting
        && (template.revalidates() ||
        template.uses_incremental() ||
        template.uses_request_state() ||
        // We check amalgamation as well because it involves request state, even if that wasn't provided
        template.can_amalgamate_states())
    {
        return Err(ExportError::TemplateNotExportable {
            template_name: template_path.clone(),
        }
        .into());
    }
    // Handle static path generation
    // Because we iterate over the paths, we need a base path if we're not generating custom ones (that'll be overriden if needed)
    let paths = match template.uses_build_paths() {
        true => template
            .get_build_paths()
            .await?
            // Trim away any trailing `/`s so we don't insert them into the render config
            // That makes rendering an index page from build paths impossible (see #39)
            .iter()
            .map(|p| match p.strip_suffix('/') {
                Some(stripped) => stripped.to_string(),
                None => p.to_string(),
            })
            .collect(),
        false => {
            single_page = true;
            vec![String::new()]
        }
    };
    // Iterate through the paths to generate initial states if needed
    // Note that build paths pages on incrementally generable pages will use the immutable store
    let mut futs = Vec::new();
    for path in paths.iter() {
        let fut = gen_state_for_path(path, template, translator, (immutable_store, mutable_store));
        futs.push(fut);
    }
    try_join_all(futs).await?;
    Ok((paths, single_page))
}
pub async fn build_template ( template : & Template < SsrNode > , translator : & Translator , ( immutable_store , mutable_store ) : ( & ImmutableStore , & impl MutableStore ) , exporting : bool , ) -> Result < ( Vec < String > , bool ) , ServerError > { let mut single_page = false ; let template_path = template . get_path ( ) ; // If we're exporting, ensure that all the template's strategies are export-safe (not requiring a server) if exporting && ( template . revalidates ( ) || template . uses_incremental ( ) || template . uses_request_state ( ) || // We check amalgamation as well because it involves request state, even if that wasn't provided template . can_amalgamate_states ( ) ) { return Err ( ExportError :: TemplateNotExportable { template_name : template_path . clone ( ) , } . into ( ) ) ; } // Handle static path generation // Because we iterate over the paths, we need a base path if we're not generating custom ones (that'll be overriden if needed) let paths = match template . uses_build_paths ( ) { true => template . get_build_paths ( ) . await ? // Trim away any trailing `/`s so we don't insert them into the render config // That makes rendering an index page from build paths impossible (see #39) . iter ( ) . map ( | p | match p . strip_suffix ( '/' ) { Some ( stripped ) => stripped . to_string ( ) , None => p . to_string ( ) , } ) . collect ( ) , false => { single_page = true ; vec ! [ String new ( ) ] } } ; // Iterate through the paths to generate initial states if needed // Note that build paths pages on incrementally generable pages will use the immutable store let mut futs = Vec :: new ( ) ; for path in paths . iter ( ) { let fut = gen_state_for_path ( path , template , translator , ( immutable_store , mutable_store ) ) ; futs . push ( fut ) ; } try_join_all ( futs ) . await ? ; Ok ( ( paths , single_page ) ) }
Builds a template, writing static data as appropriate.
Builds a template writing static data as appropriate .
template
&Template<SsrNode>
translator
(&ImmutableStore, &impl MutableStore)
exporting
bool