diff --git a/README.md b/README.md index a212717..2306383 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ Anything of the form `$name$` will look up `name.txt` in `$MU_WILDCARD_BASEDIR` For example: ``` $z = realistic, photo -$foo($a, $b=idles) = { $z, this is a $a that $b } -$foo(car) +$foo($a, $b=sporty, $c=default thing) = { $c, $z, a $b $a } +$foo(car, $c=another thing) ``` -expands to `realistic, photo, this is a car that idles` +expands to `another thing, realistic, photo, a sporty car` Variables can be defined inside functions and are local to the function @@ -28,7 +28,10 @@ You can define multiple variables per line by separating them with `;` Note that variables and functions can be defined *anywhere* in the prompt, meaning that `a $foo = bar` will define `$foo` and expand into just `a `. This might cause weird behaviour if you want to do complicated things with `MUJinjaRender`. -`"text"` can be used to quote something when it would conflict with syntax, for example: `$func("parameter, with comma", second parameter)`. If you need a " by itself, use "". +`"text"` can be used to quote something when it would conflict with syntax, for example: `$func("parameter, with comma", second parameter)`. If you need a " by itself, use `""`. + +#### Default functions +There are some default functions available. put `$help()` in your prompt to see a list of available functions. ## MUJinjaRender You can use this node to evaluate a string as a Jinja2 template. Note, however, that because ComfyUI's frontend uses `{}` for syntax, There are the following modifications to Jinja syntax: diff --git a/utils/parse.py b/utils/parse.py index 2286b7c..1c3d81f 100644 --- a/utils/parse.py +++ b/utils/parse.py @@ -117,6 +117,8 @@ def showarg(a): def print_context_functions(ctx): log.info("Functions available:") + log.info("- $help(), shows this help") + log.info("- $($expr), evaluates $expr as jinja") for v, val in ctx.vars.items(): if isinstance(val, tuple): log.info(f"- ${v}({','.join(showarg(a) for a in val[1])})") diff --git a/utils/wildcards.py b/utils/wildcards.py index ba1ba00..52df934 100644 --- a/utils/wildcards.py +++ b/utils/wildcards.py @@ -8,7 +8,6 @@ import mmap from .parse import parse -import folder_paths # from .parse import parse @@ -202,6 +201,7 @@ class MUSimpleWildcard: try: from server import PromptServer + import folder_paths PromptServer.instance.add_on_prompt_handler(wildcard_prompt_handler) except ImportError: