leptos-use/template/src/{{ module }}/{{ function_name }}.ffizer.hbs.rs

50 lines
1.7 KiB
Rust
Raw Normal View History

2023-06-16 19:33:55 +01:00
use default_struct_builder::DefaultBuilder;
use leptos::*;
2023-07-28 21:03:18 +01:00
///{{#if (eq unstable_apis "true")}}
2023-06-16 19:33:55 +01:00
///
2023-07-28 21:03:18 +01:00
/// > This function requires `--cfg=web_sys_unstable_apis` to be activated as
/// [described in the wasm-bindgen guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html).{{/if}}
2023-06-16 19:33:55 +01:00
///
/// ## Demo
///
/// [Link to Demo](https://github.com/Synphonyte/leptos-use/tree/main/examples/{{ function_name }})
///
/// ## Usage
///
/// ```
/// # use leptos::*;
2023-07-14 05:48:37 +01:00
/// # use leptos_use{{#if module}}::{{ module }}{{/if}}::{{ function_name }};
2023-06-16 19:33:55 +01:00
/// #
/// # #[component]
2023-07-27 18:06:36 +01:00
/// # fn Demo() -> impl IntoView {
/// {{ function_name }}();
2023-06-16 19:33:55 +01:00
/// #
2023-07-27 18:06:36 +01:00
/// # view! { }
2023-06-16 19:33:55 +01:00
/// # }
/// ```{{#if feature}}
2023-06-24 01:12:43 +01:00
// #[doc(cfg(feature = "{{feature}}"))]{{/if}}
2023-07-27 18:06:36 +01:00
pub fn {{ function_name }}() -> {{ to_pascal_case function_name }}Return {
{{ function_name }}_with_options({{ to_pascal_case function_name }}Options::default())
2023-06-16 19:33:55 +01:00
}
/// Version of [`{{ function_name }}`] that takes a `{{ to_pascal_case function_name }}Options`. See [`{{ function_name }}`] for how to use.{{#if feature}}
2023-06-24 01:12:43 +01:00
// #[doc(cfg(feature = "{{feature}}"))]{{/if}}
2023-07-27 18:06:36 +01:00
pub fn {{ function_name }}_with_options(options: {{ to_pascal_case function_name }}Options) -> {{ to_pascal_case function_name }}Return {
2023-06-16 19:33:55 +01:00
{{ to_pascal_case function_name }}Return {}
}
/// Options for [`{{ function_name }}_with_options`].{{#if feature}}
2023-06-24 01:12:43 +01:00
// #[doc(cfg(feature = "{{feature}}"))]{{/if}}
2023-06-16 19:33:55 +01:00
#[derive(DefaultBuilder)]
pub struct {{ to_pascal_case function_name }}Options {}
impl Default for {{ to_pascal_case function_name }}Options {
fn default() -> Self {
Self {}
}
}
2023-06-24 01:12:43 +01:00
/// Return type of [`{{ function_name }}`].{{#if feature}}
// #[doc(cfg(feature = "{{feature}}"))]{{/if}}
2023-06-16 19:33:55 +01:00
pub struct {{ to_pascal_case function_name }}Return {}