forked from adieyal/sd-dynamic-prompts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jinja_help.html
57 lines (50 loc) · 1.99 KB
/
jinja_help.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<div class="dynamic-prompting">
Jinja2 templates is an experimental feature for advanced template generation. It is not recommended for general use unless you are comfortable with writing scripts.<br><br>
<h3>Literals</h3>
<pre><code class="codeblock">
I love red roses
</code></pre>
<h3>Random choices</h3>
<pre><code class="codeblock">
I love {{ choice('red', 'blue', 'green') }} roses
</code></pre>
This will randomly choose one of the three colors.<br><br>
<h3>Iterations</h3>
<pre>
<code class="codeblock">
{% for colour in ['red', 'blue', 'green'] %}
{% prompt %}I love {{ colour }} roses{% endprompt %}
{% endfor %}
</code>
</pre>
This will produce three prompts, one for each color. The prompt tag is used to mark the text that will be used as the prompt. If no prompt tag is present then only one prompt is assumed<br><br>
<h3>Wildcards</h3>
<pre>
<code class="codeblock">
{% for colour in wildcard("__colours__") %}
{% prompt %}I love {{ colour }} roses{% endprompt %}
{% endfor %}
</code>
</pre>
This will produce one prompt for each colour in the wildcard.txt file. <br><br>
<h3>Conditionals</h3>
<pre>
<code class="codeblock">
{% for colour in ["red", "blue", "green"] %}
{% if colour == "red" %}
{% prompt %}I love {{ colour }} roses{% endprompt %}
{% else %}
{% prompt %}I hate {{ colour }} roses{% endprompt %}
{% endif %}
{% endfor %}
</code>
</pre>
This will produce the following prompts:
<ul>
<li>I love red roses</li>
<li>I hate blue roses</li>
<li>I hate green roses</li>
</ul><br>
Jinja2 templates are based on the Jinja2 template engine. For more information see the <a href="https://jinja.palletsprojects.com/en/3.1.x/templates/">Jinja2 documentation.</a>.<br>
If you are using these templates, please let me know if they are useful.
</div>