Releases: KaioFelps/inertia-rust
Releases · KaioFelps/inertia-rust
v2.4.0
v2.4.0
Added
ViteHBSTemplateResolver
, which uses Handlebars as template engine.
Changed
- Merged
inner_render
andinner_render_with_props
methods; - Updated the docs for using
ViteHBSTemplateResolver
by default; - Deprecated
ViteTemplateResolver
.
Removed
template_path
field and setters fromInertia
andInertiaConfigBuilder
;
Breaking
Template Resolvers
template_path
has been removed from Inertia struct. Now, it's the template resolver's responsability to fetch and
parse the template HTML. This means ViteTemplateResolver
now is the one who takes the template path on initialization.
Also, its new
method now returns a Result<ViteTemplateResolver, InertiaError>
instead of ViteTemplateResolver
directly, since it looks for the root template in the given path and return an error if it can't find the file.
let vite = initialize_vite().await;
- let resolver = ViteTemplateResolver::new(vite);
+ let resolver = ViteTemplateResolver::new(vite, "www/root.html").unwrap();
let inertia = Inertia::new(
InertiaConfig::builder()
.set_url("http://localhost:8080")
.set_version(InertiaVersion::Literal(ASSETS_VERSION.get().unwrap()))
- .set_template_path("www/root.html")
.set_template_resolver(Box::new(resolver))
.enable_ssr()
.set_ssr_client(SsrClient::new("127.0.0.1", 1000))
.build(),
);
v2.3.8
v2.3.7
v2.3.6
v2.3.6
Added
- Added new features:
validator
,actix-validator
; - Added
InertiaValidateOrRedirect
trait for validating or generating an error redirect
(ifvalidator
feature is enabled); - Implemented
InertiaValidateOrRedirect
for actix-web (ifactix-validator
is enabled).
Changed
Inertia::back_with_errors
hashmap keys are now anything that implementsToString
trait.
v2.3.5
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.3.0
Added
IntoInertiaPropResult
trait, which introducesinto_inertia_value
.
Changed
InertiaProp
enums now require eitherResult<Value, InertiaError>
or an async callback that returns it;InertiaProp
enum constructors automatic serializes and map the error toInertiaError
;render_with_props
now will immediately return anInertiaError
if any prop fails to be resolved.
Breaking Changes
Serializing Props
Instead of calling to_value(...).unwrap()
, you must call into_inertia_value
into a serializable object.
This applies for InertiaProp
s which takes a callback and also for any prop that is being instantiating
directly.
use inertia_rust::{
hashmap,
prop_resolver,
InertiaProp,
+ IntoInertiaError;
};
- use serde_json::to_value;
hashmap![
- "foo" => InertiaProp::Data(to_value("Foo").unwrap()),
+ "foo" => InertiaProp::Data("Foo".into_inertia_value()),
"users" => InertiaProp::defer(prop_resolver!(
let users_clone = users.clone(); {
let counter = TIMES_DEFERRED_RESOLVER_HAS_EXECUTED.get_or_init(|| Arc::new(Mutex::new(0)));
*counter.lock().unwrap() += 1;
- to_value(users_clone
+ users_clone
.clone()
.iter()
.skip((page -1)* per_page)
.take(per_page)
.cloned()
.collect::<Vec<_>>()
- ).unwrap()
+ .into_inertia_value()
}))
.into_mergeable(),
"permissions" => InertiaProp::merge(permissions.into_iter().skip((page-1)*per_page).take(per_page).collect::<Vec<_>>())
],