mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
properly handle web-sys unstable apis config in the new function template
This commit is contained in:
parent
365b705bf5
commit
ae1676c786
3 changed files with 11 additions and 3 deletions
|
@ -19,4 +19,4 @@ ignores:
|
|||
- createfn.sh
|
||||
|
||||
scripts:
|
||||
- cmd: python3 template/modify_files.py {{ function_name }} {{ category }}{{#if module}} --module {{ module }}{{/if}} --feature {{ feature }}
|
||||
- cmd: python3 template/modify_files.py {{ function_name }} {{ category }}{{#if module}} --module {{ module }}{{/if}} --feature {{ feature }} --unstable_apis {{ unstable_apis }}
|
||||
|
|
|
@ -10,6 +10,7 @@ def main():
|
|||
parser.add_argument("category")
|
||||
parser.add_argument("--module", type=str)
|
||||
parser.add_argument("--feature", type=str)
|
||||
parser.add_argument("--unstable_apis", type=lambda x: x.lower() == "true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -94,7 +95,14 @@ def modify_librs(args):
|
|||
with open("src/lib.rs", "r") as f:
|
||||
lib_source = f.read()
|
||||
|
||||
feature_prefix = "" if args.feature is None else f"#[cfg(feature = \"{args.feature}\")]\n"
|
||||
feature_prefix = []
|
||||
if args.feature is not None:
|
||||
feature_prefix.append(f"#[cfg(feature = \"{args.feature}\")]\n")
|
||||
|
||||
if args.unstable_apis:
|
||||
feature_prefix.append("#[cfg(web_sys_unstable_apis)]\n")
|
||||
|
||||
feature_prefix = "".join(feature_prefix)
|
||||
|
||||
if args.module is None:
|
||||
lib_source = lib_source.replace("mod on_click_outside;",
|
||||
|
@ -163,5 +171,6 @@ def modify_cargo_toml(args):
|
|||
with open("Cargo.toml", "w") as f:
|
||||
f.write("".join(cargo_toml_source))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -27,7 +27,6 @@ use leptos::*;
|
|||
/// ## Server-Side Rendering
|
||||
///
|
||||
// #[doc(cfg(feature = "{{feature}}"))]
|
||||
|
||||
pub fn {{ function_name }}() -> {{ to_pascal_case function_name }}Return {
|
||||
{{ function_name }}_with_options({{ to_pascal_case function_name }}Options::default())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue