Skip to main content

Crate lib_humus

Crate lib_humus 

Source
Expand description

lib-humus helps with some fertile ground to build a web project on.

§What is lib-humus?

lib-humus is an opinioated, pre-assembled templating engine that takes care of the frontend for a web application that builds on top of the axum framework.

Its main use is in your handler functions right at the end to turn data from your application into the response that the client wants, be it HTML, plain text, json or something else.

It allows you to focus on the data and the templates without having to worry about template engine details.

Under the hood it uses well known crates like tera for templates and fluent for localization.

§lib-humus is a family

§Overview

The original idea behind this is that all the data that gets rendered as html should also be available as a JSON-API (and other formats if useful). The HTML should also come from easily replaceable templates that are themselves configurable.

The HumusEngine helps you with that, it generated an appropriate response given a HumusView and HumusQuerySettings.

The HumusView providing the data and metadata for the frontend in the form of being serde serializable and through a number of callbacks and hooks.

The HumusQuerySettings instance provides information on how to render the result.

Loading the templates and the template configuration can be done using the HumusEngineLoader.

The HumusQuerySettings can be obtanied by adding a TemplateSettingsLayer as an axum middleware.

The LanguageEngine is provided to both the templates and your code to generate localized responses.

This library is derived from (and now used by) the echoip-slatecave service.

For more documentation see the doc module.

§Feature-flags

Feature flags have been removed in version 0.6.

Modules§

crates
This module cotnains reexports of lib-humus dependencies that are exposed through the API.
doc
Documentation module
headers
This module contains structs for decoding HTTP headers that are not in the headers (via axum_extra) crate.
language
This module houses everything relating to localization and translation built into lib-humus.
middleware
Useful middleware to extract template settings for use with the templates.
templating
Contains all the types that are specific to templating
util
This module provides helper functions.

Structs§

HumusEngine
🌱 An all in one datatype that takes care of frontend rendering.
HumusEngineLoader
Helps loading a HumusEngine from disk.

Enums§

HumusEngineLoaderError
Returned when loading a template using the HumusEngineLoader fails.

Traits§

HumusQuerySettings
Provides context from the query for use in the crate::HumusEngine.
HumusView
👁 Provides data and logic for the HumusEngine and knows how to put information together.