pub(crate) fn page_data(
        mut self,
        page_data: &PageData,
        global_state: &TemplateState,
        locale: &str,
    ) -> Self {
        self.locale = locale.to_string();
        // Interpolate a global variable of the state so the app shell doesn't have to
        // make any more trips The app shell will unset this after usage so it
        // doesn't contaminate later non-initial loads Error pages (above) will
        // set this to `error`
        let initial_state = escape_page_data(&page_data.state.to_string());
        // We know the form of this, and it won't fail
        let initial_widget_states =
            escape_page_data(&serde_json::to_string(&page_data.widget_states).unwrap());
        let global_state = escape_page_data(&global_state.state.to_string());

        // We put this at the very end of the head (after the delimiter comment) because
        // it doesn't matter if it's expunged on subsequent loads
        let initial_state = format!("window.__PERSEUS_INITIAL_STATE = `{}`;", initial_state);
        self.scripts_after_boundary.push(initial_state);
        let initial_widget_states = format!(
            "window.__PERSEUS_INITIAL_WIDGET_STATES = `{}`;",
            initial_widget_states
        );
        self.scripts_after_boundary.push(initial_widget_states);
        // But we'll need the global state as a variable until a template accesses it,
        // so we'll keep it around (even though it should actually instantiate validly
        // and not need this after the initial load)
        let global_state = format!("window.__PERSEUS_GLOBAL_STATE = `{}`;", global_state);
        self.scripts_before_boundary.push(global_state);

        // Now import the constants we'll need for the initial load of this locale
        // (i.e. render config and translations)
        //
        // We can put all this after the boundary, because everything will be
        // automatically cached for later use
        let consts_import = format!(
            "<script src=\".perseus/initial_consts/{}.js\"></script>",
            locale
        );
        self.head_after_boundary.push(consts_import);

        // Interpolate the document `<head>` (this should of course be removed between
        // page loads)
        self.head_after_boundary.push((&page_data.head).into());
        // And set the content
        self.content = (&page_data.content).into();

        self
    }
Interpolates page data, global state, and translations into the shell.

The translations provided should be the source string from which a
translator can be derived on the client-side. These are provided in
a window variable to avoid page interactivity requiring a network
request to get them.

This needs to know what the locale is so it can set the HTML `lang`
attribute for improved SEO.
packages/perseus/src/server/html_shell.rs