Product 1 ({{< product type="prod1" >}}) is really great.
{{< product type="prod2" >}}
prod3
is unknown in shortcode product.html
(see dict
there).
{{< product type="prod3" >}}
{{< product "prod1" >}}
{{< product "prod2" >}}
Product 1 ({{< product type="prod1" >}}) is really great.
{{< product type="prod2" >}}
prod3
is unknown in shortcode product.html
(see dict
there).
{{< product type="prod3" >}}
{{< product "prod1" >}}
{{< product "prod2" >}}
{{- $product := "" -}} | |
{{- if .IsNamedParams -}} | |
{{- $product = .Get "type" -}} | |
{{- else -}} | |
{{- $product = .Get 0 -}} | |
{{- end -}} | |
{{- $products := dict | |
"prod1" "Orange" | |
"prod2" "Apple" | |
"NO_PRODUCT_MATCHES" "No product found for key \"%s\"!" | |
-}} | |
{{- $output := index $products $product -}} | |
{{- if not $output -}} | |
{{- $output = printf (index $products "NO_PRODUCT_MATCHES") $product -}} | |
{{- end -}} | |
{{- $output -}} |
<h2>Product 1 with named param</h2> | |
<p>Product 1 (Orange) is really great.</p> | |
<h2>Product 2 with named param</h2> | |
Apple | |
<h2>Product 3 with named param</h2> | |
<p><code>prod3</code> is unknown in shortcode (see <code>dict</code> there).</p> | |
No product found for key "prod3"! | |
<h2>Product 1</h2> | |
Orange | |
<h2>Product 2</h2> | |
Apple |
awesome! thank you