fpm::utils
fpm::utils is a bunch of private helper functions.
fpm::utils::replace_markers()
When generating HTML files, we use a template. The templates contain special markers eg __ftd_doc_title__. fpm::utils::replace_markers() replaces all those markers with the dynamically generated values.
pub(crate) fn replace_markers(
    s: &str,
    config: &fpm::Config,
    main_id: &str,
    title: &str,
    base_url: &str,
    main_rt: &ftd::Document,
) -> String
__ftd_doc_title__
This is title of the document. We get this parameter as an argument to the replace_markers() function.
__ftd_canonical_url__

This is the canonical url for the page.

This is generated by fpm::Package::generate_canonical_url().

__ftd_js__

The ftd.js file content from ftd crate is included in the generated HTML file. We get this from ftd::js().

In fact we have written a wrapper, fpm::ftd_js() which returns a constant string “FTD_JS” when we are running this function under test. We do this so that our html snapshot files do not contain the entire js, to reduce the content size in git, and also to ensure tests do not fail when we update ftd and ftd::js() changes.

__ftd_body_events__

This contains the content of events on body. We find this from ftd::Document.body_events.

Note: We will soon refactor and remove this key, and will just use __ftd_data_main__.

__ftd_css__
Same as __ftd_js__, but for ftd::css(). We use fpm::ftd_css() wrapper here too.
__fpm_js__
We have a fpm.js file in our repo that we want to include in all generated HTML as well. We only include the actual file content when not running in test mode. In test mode we include “FPM_JS” string.
__ftd_data_main__
The ftd variables, dependencies etc are serialised into JSON and stored here.
__ftd_external_children_main__

We store information about “external children” here.

Note: We will soon refactor and remove this key, and will just use __ftd_data_main__.

__main__
The rendered HTML is used here.
/
This is the base URL.