Is there a way to test if a snippet exists before using it within a
template?
I'm creating a provisioning template. I want it to include a user snippet
if it exists, otherwise fall back to a default snippet.
Roughly something functionally equivalent to like this…
<% if snippet("snippet.custom").nil? %>
snippet("snippet.default")
<% else
snippet("snippet.custom")
<% end %>
Is there a way to accomplish this?
This did the trick: snippet_if_exists("snippet.custom")
···
On Tuesday, December 29, 2015 at 12:30:19 PM UTC-8, Kyle Flavin wrote:
>
> Is there a way to test if a snippet exists before using it within a
> template?
>
> I'm creating a provisioning template. I want it to include a user snippet
> if it exists, otherwise fall back to a default snippet.
>
> Roughly something functionally equivalent to like this...
>
> <% if snippet("snippet.custom").nil? %>
> snippet("snippet.default")
> <% else
> snippet("snippet.custom")
> <% end %>
>
>
>
> Is there a way to accomplish this?
>