With the Pro version of Snippets, you can pass "variables" to the {snippet}
tag that can make your snippet more dynamic.
This allows you to use one snippet that will generate a different output depending on what you pass along in the tag.
Then in the text of the Snippet, you can put placeholders for those variables with %myvariable%
.
Text of the Snippet
So, for example, in a copyright
Snippet, your Snippet text could look like:
%year% - %company% - All rights reserved
Placing the Snippet
And then, in an article, you can pass along the two variables via the tag, like this:
{snippet alias="copyright" company="My Company" year="2019"}
Output Result
{snippet alias="copyright" company="My Company" year="2019"}
{snippet alias="copyright" company="Another Company" year="2015"}
Default variable placeholder
In the Snippet text, you can also enter a default placeholder for when a variable is not passed via the snippet tag
You do this by appending the variable name with :
and your default value. For example, to set the year
variable to 2021 by default:
%year:2021% - %company% - All rights reserved
You would then be free to omit the year
variable from the snippet tag.
And you would get this result, with the year defaulting to 2021:
{snippet alias="copyright" company="My Company"}