Calling Snippets with Arguments¶
Flamingo IDE lets you call snippets with arguments and this topic explains how to perform such action:
- Open the snippet you need to use arguments in.
- To access to the arguments available in snippet, use the standard JavaScript command arguments . For example:
<!--{= arguments[n] }-->
where n is the index number of the element in the array. You can work with this array as with an ordinary array.
Note that you can define any number of arguments to return afterwards.
- Call snippet with arguments in your template by adding
<!--{ call sample_snippet(paramN) }-->
where paramN is any JavaScript object like string, boolean value, array, JSON object, etc.
-OR-
Use the Arguments field in the Snippet popup window:
Note that you can specify any number of arguments separating them with comma, for example:
<!–{ call sample_snippet(paramN, paramN1, paramN2) }–>
Usage examples¶
Example 1 : Using Boolean Values in Arguments
Shows how to execute or cancel executing code available in the snippet.
Example 2 : Correcting and Displaying Data
Shows how to modify data provided on the desktop site page and return it on mobile site.
Example 3 : Snippet Output Using JavaScript Object as Argument
Shows how to manage snippet output using JavaScript object as an argument.
See also