Imprint

by Marcel Garus · 1 minute read · available at mgar.us/imprint

Marcel Garus

Enfieldstr. 85
45966 Gladbeck

imprint@marcelgarus.dev
+49 15751770663

This website contains links to external websites – mainly the mgar.us/go/... URLs redirect to external websites. In general, I do not have control over their content. Therefore, I do not accept any liability for this third-party content. The respective provider or operator is ultimately responsible for the content of the linked pages.

Thanks for reading!

If you liked this article, feel free to share it using this shortlink:

By the way, I wrote other articles about interesting topics. Here's an article I recommend:

Templating engine? No thanks.

2021-11-12 · 2 minute read · this blog

Here is the Rust code that produces the page you're currently reading (at least at the time of writing). Some time ago, a friend of mine asked me why I used this home-grown templating mechanism instead of a standard like mustache.

Admittedly, this might look very hacky on first impression:

async fn article_full(article: &Article, suggestion: &Article) -> String {
    fs::read_to_string("assets/article-full.html")
        .await
        .unwrap()
        .fill_in_article(&article)
        .replace("{{ suggestion-key }}", &suggestion.key)
        .replace("{{ suggestion-title }}", &suggestion.title)
}

It's just loading the template file and then replacing some strings! (If you wonder about fill_in_article(&article), that also does nothing more than replacing some strings.)