pub fn render_policy_template(
template: &str,
script_hashes: &[String],
style_hashes: &[String],
) -> StringExpand description
Renders a CSP policy template, expanding the {script_hashes} and
{style_hashes} slots into space-prefixed 'sha256-…' sources.
Empty slices render to an empty string, so a template rendered
with no hashes reduces to its hash-free form (for
DEFAULT_CSP_POLICY_TEMPLATE that is exactly
DEFAULT_CSP_POLICY). The output never contains
'unsafe-inline' unless the template itself does.
§Examples
use ssg::csp::{render_policy_template, DEFAULT_CSP_POLICY, DEFAULT_CSP_POLICY_TEMPLATE};
let empty = render_policy_template(DEFAULT_CSP_POLICY_TEMPLATE, &[], &[]);
assert_eq!(empty, DEFAULT_CSP_POLICY);
let one = render_policy_template(
DEFAULT_CSP_POLICY_TEMPLATE,
&["sha256-abc".to_string()],
&[],
);
assert!(one.contains("script-src 'self' 'sha256-abc';"));