Skip to content

Commit 7a26856

Browse files
Shadlpil
authored andcommitted
split snippet in snipMate & UltiSnips format
snipMate for the plain simple snippets UltiSnips for the four snippets with choices selection (append, assign, config_load, include)
1 parent 83f437b commit 7a26856

File tree

2 files changed

+140
-142
lines changed

2 files changed

+140
-142
lines changed

UltiSnips/smarty.snippets

Lines changed: 1 addition & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,6 @@ extends html
44
extends javascript
55
extends css
66

7-
# https://www.smarty.net/docs/en/language.function.if.tpl
8-
snippet if "{if cond} ... {/if}"
9-
{if ${1}}
10-
${0:${VISUAL}}
11-
{/if}
12-
endsnippet
13-
14-
snippet ifn "{if !cond} ... {/if}"
15-
{if ${1}}
16-
${0:${VISUAL}}
17-
{/if}
18-
endsnippet
19-
20-
snippet ife "{if cond} ... {else} ... {/if}"
21-
{if ${1}}
22-
${0:${VISUAL}}
23-
{else}
24-
${2}
25-
{/if}
26-
endsnippet
27-
28-
snippet eif "{elseif cond} ... {/if}"
29-
{elseif ${1}}
30-
${0:${VISUAL}}
31-
{/if}
32-
endsnippet
33-
34-
snippet el "{else} ... {/if}"
35-
{else}
36-
${1}
37-
{/if}
38-
endsnippet
39-
40-
# https://www.smarty.net/docs/en/language.function.for.tpl
41-
snippet for "The {for} tag is used to create simple loops."
42-
{for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}}
43-
${0:${VISUAL}}
44-
{/for}
45-
endsnippet
46-
47-
snippet forelse "The {for}{forelse} tag is used to create simple loops."
48-
{for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}}
49-
${0:${VISUAL}}
50-
{forelse}
51-
${8}
52-
{/for}
53-
endsnippet
54-
55-
# https://www.smarty.net/docs/en/language.function.foreach.tpl
56-
snippet foreach "{foreach} is used for looping over arrays of data."
57-
{foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}}
58-
${0:${VISUAL}}
59-
{/foreach}
60-
endsnippet
61-
62-
snippet foreach2 "[Smarty2] {foreach} is used for looping over arrays of data."
63-
{foreach from='$${1:collection} item='${2}'${3: key='${4}'}${5: name='${6}'}}
64-
${0:${VISUAL}}
65-
{/foreach}
66-
endsnippet
67-
68-
snippet foreachelse "{foreach} is used for looping over arrays of data."
69-
{foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}}
70-
${0:${VISUAL}}
71-
{foreachelse}
72-
${5}
73-
{/foreach}
74-
endsnippet
75-
76-
snippet wh "{while} loops in Smarty have much the same flexibility as PHP while statements, with a few added features for the template engine. Every {while} must be paired with a matching {/while}. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc."
77-
{while ${1} }
78-
${0:${VISUAL}}
79-
{/while}
80-
endsnippet
81-
827

838

849

@@ -92,78 +17,12 @@ snippet assign "{assign} is used for assigning template variables during the exe
9217
{assign var='${1}' value='${2}'${3: scope='${4|parent,root,global|}'}}
9318
endsnippet
9419

95-
# https://www.smarty.net/docs/en/language.function.block.tpl
96-
snippet block "{block} is used to define a named area of template source for template inheritance."
97-
{block name='${1}'}
98-
${0:${VISUAL}}
99-
{/block}
100-
endsnippet
101-
102-
# https://www.smarty.net/docs/en/language.function.call.tpl
103-
snippet call "{call} is used to call a template function defined by the {function} tag just like a plugin function."
104-
{call name=${1}${2: assign=${3}}${4: variables}}
105-
endsnippet
106-
107-
# https://www.smarty.net/docs/en/language.function.capture.tpl
108-
snippet capture "{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. "
109-
{capture name='${1}'${2: assign='${3}' }${4: append='${5:array_variable}'}}
110-
${0:${VISUAL}}
111-
{/capture}
112-
endsnippet
113-
11420
# https://www.smarty.net/docs/en/language.function.config.load.tpl
11521
snippet config_load "config_load"
116-
{config_load file='${1}'${2: section='${3}'}${4: scope='${5|local,parent,global|}'}]
117-
endsnippet
118-
119-
# https://www.smarty.net/docs/en/language.function.extends.tpl
120-
snippet extends "{extends} tags are used in child templates in template inheritance for extending parent templates."
121-
{extends file='${1}'}
122-
endsnippet
123-
124-
# https://www.smarty.net/docs/en/language.function.function.tpl
125-
snippet function "{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."
126-
{function name='${1}' ${2:variables}}
127-
${0:${VISUAL}}
128-
{/function}
22+
{config_load file='${1}'${2: section='${3}'}${4: scope='${5|local,parent,global|}'}}
12923
endsnippet
13024

13125
# https://www.smarty.net/docs/en/language.function.include.tpl
13226
snippet include "{include} tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template."
13327
{include file='${1}'${2: assign='${3}'}${4: cache_lifetime=${5}}${6: compile_id='${7}'}${8: cache_id='${9}'}${10: scope='${11|parent,root,global|}'}${12: variables}}
13428
endsnippet
135-
136-
# https://www.smarty.net/docs/en/language.function.literal.tpl
137-
snippet literal "{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"
138-
{literal}
139-
${0:${VISUAL}}
140-
{/literal}
141-
endsnippet
142-
143-
# https://www.smarty.net/docs/en/language.function.nocache.tpl
144-
snippet nocache "{nocache} is used to disable caching of a template section. Every {nocache} must be paired with a matching {/nocache}."
145-
{nocache}
146-
${0:${VISUAL}}
147-
{/nocache}
148-
endsnippet
149-
150-
# https://www.smarty.net/docs/en/language.function.section.tpl
151-
snippet section "A {section} is for looping over sequentially indexed arrays of data, unlike {foreach} which is used to loop over a single associative array. Every {section} tag must be paired with a closing {/section} tag."
152-
{section name='${1}'${2: loop='${3}'}${4: start=${5}}${6: step=${7}}${8: max=${9}}${10: show=${11}}}
153-
${0:${VISUAL}}
154-
{/section}
155-
endsnippet
156-
157-
# https://www.smarty.net/docs/en/language.function.setfilter.tpl
158-
snippet setfilter "The {setfilter}...{/setfilter} block tag allows the definition of template instance's variable filters."
159-
{setfilter ${1:filters}}
160-
${0:${VISUAL}}
161-
{/setfilter}
162-
endsnippet
163-
164-
# https://www.smarty.net/docs/en/language.function.strip.tpl
165-
snippet strip "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. This way you can keep your templates readable, and not worry about extra white space causing problems."
166-
{strip}
167-
${0:${VISUAL}}
168-
{/strip}
169-
endsnippet

snippets/smarty.snippets

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# snippets for smarty3
2+
3+
extends html
4+
extends javascript
5+
extends css
6+
7+
# https://www.smarty.net/docs/en/language.function.if.tpl
8+
snippet if "{if cond} ... {/if}"
9+
{if ${1}}
10+
${0:${VISUAL}}
11+
{/if}
12+
13+
snippet ifn "{if !cond} ... {/if}"
14+
{if ${1}}
15+
${0:${VISUAL}}
16+
{/if}
17+
18+
snippet ife "{if cond} ... {else} ... {/if}"
19+
{if ${1}}
20+
${0:${VISUAL}}
21+
{else}
22+
${2}
23+
{/if}
24+
25+
snippet eif "{elseif cond} ... {/if}"
26+
{elseif ${1}}
27+
${0:${VISUAL}}
28+
{/if}
29+
30+
snippet el "{else} ... {/if}"
31+
{else}
32+
${1}
33+
{/if}
34+
35+
# https://www.smarty.net/docs/en/language.function.for.tpl
36+
snippet for "The {for} tag is used to create simple loops."
37+
{for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}}
38+
${0:${VISUAL}}
39+
{/for}
40+
41+
snippet forelse "The {for}{forelse} tag is used to create simple loops."
42+
{for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}}
43+
${0:${VISUAL}}
44+
{forelse}
45+
${8}
46+
{/for}
47+
48+
# https://www.smarty.net/docs/en/language.function.foreach.tpl
49+
snippet foreach "{foreach} is used for looping over arrays of data."
50+
{foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}}
51+
${0:${VISUAL}}
52+
{/foreach}
53+
54+
snippet foreach2 "[Smarty2] {foreach} is used for looping over arrays of data."
55+
{foreach from=$${1:collection} item='${2}'${3: key='${4}'}${5: name='${6}'}}
56+
${0:${VISUAL}}
57+
{/foreach}
58+
59+
snippet foreachelse "{foreach} is used for looping over arrays of data."
60+
{foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}}
61+
${0:${VISUAL}}
62+
{foreachelse}
63+
${5}
64+
{/foreach}
65+
66+
snippet wh "{while} loops in Smarty have much the same flexibility as PHP while statements, with a few added features for the template engine. Every {while} must be paired with a matching {/while}. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc."
67+
{while ${1}}
68+
${0:${VISUAL}}
69+
{/while}
70+
71+
72+
73+
# https://www.smarty.net/docs/en/language.function.append.tpl
74+
#snippet append implemented in UltiSnips format
75+
76+
# https://www.smarty.net/docs/en/language.function.assign.tpl
77+
#snippet assign implemented in UltiSnips format
78+
79+
# https://www.smarty.net/docs/en/language.function.block.tpl
80+
snippet block "{block} is used to define a named area of template source for template inheritance."
81+
{block name='${1}'}
82+
${0:${VISUAL}}
83+
{/block}
84+
85+
# https://www.smarty.net/docs/en/language.function.call.tpl
86+
snippet call "{call} is used to call a template function defined by the {function} tag just like a plugin function."
87+
{call name=${1}${2: assign=${3}}${4: variables}}
88+
89+
# https://www.smarty.net/docs/en/language.function.capture.tpl
90+
snippet capture "{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. "
91+
{capture name='${1}'${2: assign='${3}' }${4: append='${5:array_variable}'}}
92+
${0:${VISUAL}}
93+
{/capture}
94+
95+
# https://www.smarty.net/docs/en/language.function.config.load.tpl
96+
#snippet config_load implemented in UltiSnips format
97+
98+
# https://www.smarty.net/docs/en/language.function.extends.tpl
99+
snippet extends "{extends} tags are used in child templates in template inheritance for extending parent templates."
100+
{extends file='${1}'}
101+
102+
# https://www.smarty.net/docs/en/language.function.function.tpl
103+
snippet function "{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."
104+
{function name='${1}' ${2:variables}}
105+
${0:${VISUAL}}
106+
{/function}
107+
108+
# https://www.smarty.net/docs/en/language.function.include.tpl
109+
#snippet include implemented in UltiSnips format
110+
111+
# https://www.smarty.net/docs/en/language.function.literal.tpl
112+
snippet literal "{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"
113+
{literal}
114+
${0:${VISUAL}}
115+
{/literal}
116+
117+
# https://www.smarty.net/docs/en/language.function.nocache.tpl
118+
snippet nocache "{nocache} is used to disable caching of a template section. Every {nocache} must be paired with a matching {/nocache}."
119+
{nocache}
120+
${0:${VISUAL}}
121+
{/nocache}
122+
123+
# https://www.smarty.net/docs/en/language.function.section.tpl
124+
snippet section "A {section} is for looping over sequentially indexed arrays of data, unlike {foreach} which is used to loop over a single associative array. Every {section} tag must be paired with a closing {/section} tag."
125+
{section name='${1}'${2: loop='${3}'}${4: start=${5}}${6: step=${7}}${8: max=${9}}${10: show=${11}}}
126+
${0:${VISUAL}}
127+
{/section}
128+
129+
# https://www.smarty.net/docs/en/language.function.setfilter.tpl
130+
snippet setfilter "The {setfilter}...{/setfilter} block tag allows the definition of template instance's variable filters."
131+
{setfilter ${1:filters}}
132+
${0:${VISUAL}}
133+
{/setfilter}
134+
135+
# https://www.smarty.net/docs/en/language.function.strip.tpl
136+
snippet strip "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. This way you can keep your templates readable, and not worry about extra white space causing problems."
137+
{strip}
138+
${0:${VISUAL}}
139+
{/strip}

0 commit comments

Comments
 (0)