Macro perseus::define_app
source · [−]macro_rules! define_app {
{
$(root: $root_selector:literal,)?
templates: [
$($template:expr),+
],
error_pages: $error_pages:expr,
$(global_state_creator: $global_state_creator:expr,)?
// This deliberately enforces verbose i18n definition, and forces developers to consider i18n as integral
locales: {
default: $default_locale:literal,
// The user doesn't have to define any other locales
other: [$($other_locale:literal),*]
}
$(,static_aliases: {
$($url:literal => $resource:literal),*
})?
$(,plugins: $plugins:expr)?
$(,dist_path: $dist_path:literal)?
$(,mutable_store: $mutable_store:expr)?
$(,translations_manager: $translations_manager:expr)?
} => { ... };
{
$(root: $root_selector:literal,)?
templates: [
$($template:expr),+
],
error_pages: $error_pages:expr
$(,global_state_creator: $global_state_creator:expr)?
$(,static_aliases: {
$($url:literal => $resource:literal),*
})?
$(,plugins: $plugins:expr)?
$(,dist_path: $dist_path:literal)?
$(,mutable_store: $mutable_store:expr)?
} => { ... };
(
@define_app,
{
$(root: $root_selector:literal,)?
templates: [
$($template:expr),+
],
error_pages: $error_pages:expr,
$(global_state_creator: $global_state_creator:expr,)?
// This deliberately enforces verbose i18n definition, and forces developers to consider i18n as integral
locales: {
default: $default_locale:literal,
// The user doesn't have to define any other locales
other: [$($other_locale:literal),*],
// If this is `true`
no_i18n: $no_i18n:literal
}
$(,static_aliases: {
$($url:literal => $resource:literal),*
})?
$(,plugins: $plugins:expr)?
$(,dist_path: $dist_path:literal)?
$(,mutable_store: $mutable_store:expr)?
$(,translations_manager: $translations_manager:expr)?
}
) => { ... };
}
Expand description
Defines the components to create an entrypoint for the app. The actual entrypoint is created in the .perseus/
crate (where we can
get all the dependencies without driving the user’s Cargo.toml
nuts). This also defines the template map. This is intended to make
compatibility with the Perseus CLI significantly easier.
Warning: all properties must currently be in the correct order (root
, templates
, error_pages
, global_state_creator
, locales
, static_aliases
,
plugins
, dist_path
, mutable_store
, translations_manager
).
Note: as of v0.3.4, this is just a wrapper over PerseusAppBase
, which is the recommended way to create a new Perseus app (no macros involved).