This live template will allow you to quickly create a leptos component when creating a new file.
Will use the file name as component name. Usually names are snake cased, the script will use a camel cased version of file name for the component name. Example: file name
gallery_itemwill result in theGalleryItemcomponent.
Within your Jetbrains IDE navigate to Settings. Main menu > Settings (⌘ , in macOS or Ctrl Alt S in Windows).
Navigate to Editor > File and Code Templates.
Press + icon.
- Name:
Leptos Component - Extension:
rs - File name:
[empty] - Body:
use leptos::*;
#set( $CamelCaseName = "" )
#foreach( $str in $NAME.split("_") )
#set( $str = $str.substring(0,1).toUpperCase() + $str.substring(1) )
#set( $CamelCaseName = $CamelCaseName + $str )
#end
#[component]
pub fn ${CamelCaseName}() -> impl IntoView {
view! {
#[[ $END$ ]]#
}
}
This live template will allow you to quickly create a leptos component after input abbreviation
lcompwithin any Rust file.
Within your Jetbrains IDE navigate to Settings. Main menu > Settings (⌘ + , in macOS or Ctrl + Alt + S in Windows).
Navigate to Editor > Live Templates.
Press + icon > Template Group > Input "Leptos"
Select the new group "Leptos"
Press + icon > Live Template
- Abbreviation:
lcomp(could be anything really) - Description:
Leptos Component - Template text:
#[component]
pub fn $NAME$() -> impl IntoView {
view! {
$END$
}
}
- Applicable in:
Rust - Reformat according to style:
true