Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

include is not very efficient #1034

@GuillaumeGomez

Description

@GuillaumeGomez

Currently, code like:

<script>{%- include "theme.js" -%}</script>

generates:

        ::std::write!(
            writer,
            "</title>\n\n        <script>",
            expr2 = &::askama::MarkupDisplay::new_unsafe(&(self.csp_nonce), ::askama::Html),
        )?;
        include_bytes! ("/home/imperio/rust/docs.rs/templates/theme.js");
        writer.write_str("(function() {\n    function applyTheme(theme) {\n        if (theme) {\n            document.documentElement.dataset.docsRsTheme = theme;\n        }\n    }\n\n    window.addEventListener(\"storage\", ev => {\n        if (ev.key === \"rustdoc-theme\") {\n            applyTheme(ev.newValue);\n        }\n    });\n\n    // see ./storage-change-detection.html for details\n    window.addEventListener(\"message\", ev => {\n        if (ev.data && ev.data.storage && ev.data.storage.key === \"rustdoc-theme\") {\n            applyTheme(ev.data.storage.value);\n        }\n    });\n\n    applyTheme(window.localStorage.getItem(\"rustdoc-theme\"));\n})();")?;
        writer.write_str("</script>")?;

It duplicates the content of the file instead of just doing write!("<script>{}</script>", include_str!("theme.js"));.

Planning to send a fix for this "soon".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions