Skip to content

Instantly share code, notes, and snippets.

@Heipry
Created October 28, 2022 07:45
Show Gist options
  • Save Heipry/c42207cb3ebf94c7dd01bdfa3bb06501 to your computer and use it in GitHub Desktop.
Save Heipry/c42207cb3ebf94c7dd01bdfa3bb06501 to your computer and use it in GitHub Desktop.
Smarty template support vscode extension snippets
"append": {
	"prefix": "append",
	"body": "{append var=\"${1:name}\" value=\"${2:value}\" index=\"${3:last}\"}$0",
	"description": "{append} is used for creating or appending template variable arrays during the execution of a template.",
},
"assign": {
	"prefix": "assign",
	"body": "{assign var=\"${1:name}\" value=${2:value}${4: scope=${3:scope}}}$0",
	"description": "{assign} is used for assigning template variables during the execution of a template.",
},
"block": {
	"prefix": "block",
	"body": "{block name=${1:name}}\n\t$0\n{/block}",
	"description": "{block} is used to define a named area of template source for template inheritance.",
},
"/block": {
	"prefix": "/block",
	"body": "{/block}$0",
},
"break": {
	"prefix": "break",
	"body": "{break}$0",
	"description": "{break} aborts the iteration of the array.",
},
"capture": {
	"prefix": "capture",
	"body": "{capture ${2:name=\"${1:name}\" }${4:assign=\"${3:variable}\" }${6:append=\"${5:array_variable}\"}}\n\t$0\n{/capture}",
	"description": "{capture} is used to collect the output of the template between the tags into a variable instead of displaying it. Any content between {capture name='foo'} and {/capture} is collected into the variable specified in the name attribute.",
},
"/capture": {
	"prefix": "/capture",
	"body": "{/capture}$0",
},
"case": {
	"prefix": "case",
	"body": "{case ${1:case_name}}\n\t$0\n\t${2:{break}}",
},
"comment": {
	"prefix": "comment",
	"body": "{* ${1:comment} *}$0",
},
"debug": {
	"prefix": "debug",
	"body": "{\\$${1:variable}|@debug_print_var}$0",
	"description": "{debug} dumps the debug console to the page.",
},
"else": {
	"prefix": "else",
	"body": "{else}\n\t$0",
},
"elseif": {
	"prefix": "elseif",
	"body": "{elseif ${1:condition}}\n\t$0",
},
"extends": {
	"prefix": "extends",
	"body": "{extends file=\"${1:file}\"}$0",
	"description": "{extends} tags are used in child templates in template inheritance for extending parent templates.",
},
"foreach": {
	"prefix": "foreach",
	"body": "{foreach from=${1:collection} item=${2:item}${4: key=${3:key}}${6: name=${5:name}}}\n\t$0\n{/foreach}",
	"description": "{foreach} is used for looping over arrays of data.",
},
"foreachelse": {
	"prefix": "foreachelse",
	"body": "{foreachelse}$0",
},
"/foreach": {
	"prefix": "/foreach",
	"body": "{/foreach}$0",
},
"function": {
	"prefix": "function",
	"body": "{function name=\"${1:name}\" ${2:variables}}\n\t$0\n{/function}",
	"description": "{function} is used to create functions within a template and call them just like a plugin function. Instead of writing a plugin that generates presentational content, keeping it in the template is often a more manageable choice. It also simplifies data traversal, such as deeply nested menus.",
},
"/function": {
	"prefix": "/function",
	"body": "{/function}$0",
},
"if": {
	"prefix": "if",
	"body": "{if ${1:condition}}\n\t$0\n{/if}",
},
"/if": {
	"prefix": "/if",
	"body": "{/if}$0",
},
"ifelse": {
	"prefix": "ifelse",
	"body": "{if ${1:condition}}\n\t$2\n{else}\n\t$3\n{/if}",
},
"include": {
	"prefix": "include",
	"body": "{include file=\"${1:file}\"${3: assign=${2:name}}${6: ${4:var1}=${5:value}}}$0",
	"description": "{include} tags are used for including other templates in the current template.",
},
"literal": {
	"prefix": "literal",
	"body": "{literal}\n\t$0\n{/literal}",
	"description": "{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax.",
},
"/literal": {
	"prefix": "/literal",
	"body": "{/literal}$0",
},
"strip": {
	"prefix": "strip",
	"body": "{strip}\n\t$0\n{/strip}",
	"description": "Anything within {strip}{/strip} tags are stripped of the extra spaces or carriage returns at the beginnings and ends of the lines before they are displayed.",
},
"/strip": {
	"prefix": "/strip",
	"body": "{/strip}$0",
},
"capitalize": {
	"prefix": "|capitalize",
	"body": "|capitalize",
	"description": "This is used to capitalize the first letter of all words in a variable. This is similar to the PHP ucwords() function.",
},
"cat": {
	"prefix": "|cat",
	"body": "|cat",
	"description": "This value is concatenated to the given variable.",
},
"count_characters": {
	"prefix": "|count_characters",
	"body": "|count_characters",
	"description": "This is used to count the number of characters in a variable.",
},
"count_paragraphs": {
	"prefix": "|count_paragraphs",
	"body": "|count_paragraphs",
	"description": "This is used to count the number of paragraphs in a variable.",
},
"count_sentences": {
	"prefix": "|count_sentences",
	"body": "|count_sentences",
	"description": "This is used to count the number of sentences in a variable. A sentence being delimited by a dot, question- or exclamation-mark (.?!).",
},
"count_words": {
	"prefix": "|count_words",
	"body": "|count_words",
	"description": "This is used to count the number of words in a variable.",
	"reference": "language.modifier.count.words.tpl"
},
"date_format": {
	"prefix": "|date_format",
	"body": "|date_format",
	"description": "This formats a date and time into the given strftime() format.",
},
"default": {
	"prefix": "|default",
	"body": "|default",
	"description": "This is used to set a default value for a variable. If the variable is unset or an empty string, the given default value is printed instead. Default takes the one argument.",
},
"escape": {
	"prefix": "|escape",
	"body": "|escape",
	"description": "escape is used to encode or escape a variable to html, url, single quotes, hex, hexentity, javascript and mail. By default its html.",
},
"from_charset": {
	"prefix": "|from_charset",
	"body": "|from_charset",
	"description": "from_charset is used to transcode a string from a given charset to the internal charset. This is the exact opposite of the to_charset modifier.",
},
"indent": {
	"prefix": "|indent",
	"body": "|indent",
	"description": "This indents a string on each line, default is 4.",
},
"lower": {
	"prefix": "|lower",
	"body": "|lower",
	"description": "This is used to lowercase a variable. This is equivalent to the PHP strtolower() function.",
},
"nl2br": {
	"prefix": "|nl2br",
	"body": "|nl2br",
	"description": "All '\\n' line breaks will be converted to html <br /> tags in the given variable. This is equivalent to the PHP's nl2br() function.",
},
"regex_replace": {
	"prefix": "|regex_replace",
	"body": "|regex_replace",
	"description": "A regular expression search and replace on a variable. Use the preg_replace() syntax from the PHP manual.",
},
"replace": {
	"prefix": "|replace",
	"body": "|replace",
	"description": "A simple search and replace on a variable. This is equivalent to the PHP's str_replace() function.",
},
"spacify": {
	"prefix": "|spacify",
	"body": "|spacify",
	"description": "spacify is a way to insert a space between every character of a variable. You can optionally pass a different character or string to insert.",
},
"string_format": {
	"prefix": "|string_format",
	"body": "|string_format",
	"description": "This is a way to format strings, such as decimal numbers and such. Use the syntax for sprintf() for the formatting.",
},
"stripmodifier": {
	"prefix": "|strip",
	"body": "|strip",
	"description": "This replaces all spaces, newlines and tabs with a single space, or with the supplied string.",
},
"strip_tags": {
	"prefix": "|strip_tags",
	"body": "|strip_tags",
	"description": "This strips out markup tags, basically anything between < and >.",
},
"to_charset": {
	"prefix": "|to_charset",
	"body": "|to_charset",
	"description": "to_charset is used to transcode a string from the internal charset to a given charset. This is the exact opposite of the from_charset modifier.",
},
"truncate": {
	"prefix": "|truncate",
	"body": "|truncate",
	"description": "This truncates a variable to a character length, the default is 80.",
	"reference": "language.modifier.truncate.tpl"
},
"unescape": {
	"prefix": "|unescape",
	"body": "|unescape",
	"description": "unescape is used to decode entity, html and htmlall. It counters the effects of the escape modifier for the given types.",
},
"upper": {
	"prefix": "|upper",
	"body": "|upper",
	"description": "This is used to uppercase a variable. This is equivalent to the PHP strtoupper() function.",
},
"wordwrap": {
	"prefix": "|wordwrap",
	"body": "|wordwrap",
	"description": "Wraps a string to a column width, the default is 80. ",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment