Skip to content

Commit 93f677f

Browse files
committed
Merge pull request honza#299 from chrisyue/master
add twig snippets
2 parents acf7dc3 + 218eb0a commit 93f677f

File tree

2 files changed

+68
-13
lines changed

2 files changed

+68
-13
lines changed

UltiSnips/php/symfony2.snippets

+35-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# sugguestion? report bugs?
22
# go to https://github.com/chrisyue/vim-snippets/issues
33

4-
snippet contr "symfony2 controller" b
4+
snippet contr "Symfony2 controller" b
55
namespace `!p
66
abspath = os.path.abspath(path)
77
m = re.search(r'[A-Z].+(?=/)', abspath)
@@ -25,19 +25,19 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
2525
}
2626
endsnippet
2727

28-
snippet act "symfony2 action" b
28+
snippet act "Symfony2 action" b
2929
/**
3030
* @Route("${3}", name="${4}")
3131
* @Method({${5:"POST"}})
32+
* @Template()
3233
*/
3334
public function ${1}Action(${2})
3435
{
3536
${6}
36-
return $this->redirect($this->generateUrl('home', [], false));
3737
}
3838
endsnippet
3939

40-
snippet actt "symfony2 action and template" b
40+
snippet actt "Symfony2 action and template" b
4141
/**
4242
* @Route("${3}", name="${4}")
4343
* @Method({${5:"GET"}})
@@ -51,7 +51,7 @@ public function ${1}Action(${2})
5151
abspath = os.path.abspath(path)`
5252
endsnippet
5353

54-
snippet comm "symfony2 command" b
54+
snippet comm "Symfony2 command" b
5555
namespace `!p
5656
abspath = os.path.abspath(path)
5757
m = re.search(r'[A-Z].+(?=/)', abspath)
@@ -74,14 +74,12 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
7474
{
7575
protected function configure()
7676
{
77-
$this
78-
->setName('${1}')
77+
$this->setName('${1}')
7978
->setDescription('${2}')
8079
->setDefinition([
8180
new InputArgument('', InputArgument::REQUIRED, ''),
8281
new InputOption('', null, InputOption::VALUE_NONE, ''),
83-
])
84-
;
82+
]);
8583
}
8684

8785
protected function execute(InputInterface $input, OutputInterface $output)
@@ -90,7 +88,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
9088
}
9189
endsnippet
9290

93-
snippet subs "symfony2 subscriber" b
91+
snippet subs "Symfony2 subscriber" b
9492
namespace `!p
9593
abspath = os.path.abspath(path)
9694
m = re.search(r'[A-Z].+(?=/)', abspath)
@@ -121,7 +119,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
121119
}
122120
endsnippet
123121

124-
snippet transf "symfony2 form data transformer" b
122+
snippet transf "Symfony2 form data transformer" b
125123
namespace `!p
126124
abspath = os.path.abspath(path)
127125
m = re.search(r'[A-Z].+(?=/)', abspath)
@@ -155,7 +153,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
155153
}
156154
endsnippet
157155

158-
snippet ent "symfony2 doctrine entity" b
156+
snippet ent "Symfony2 doctrine entity" b
159157
namespace `!p
160158
abspath = os.path.abspath(path)
161159
m = re.search(r'[A-Z].+(?=/)', abspath)
@@ -192,7 +190,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
192190
}
193191
endsnippet
194192

195-
snippet form "symfony2 form type" b
193+
snippet form "Symfony2 form type" b
196194
namespace `!p
197195
abspath = os.path.abspath(path)
198196
m = re.search(r'[A-Z].+(?=/)', abspath)
@@ -235,3 +233,27 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
235233
}
236234
}
237235
endsnippet
236+
237+
snippet ev "Symfony2 event" b
238+
namespace `!p
239+
abspath = os.path.abspath(path)
240+
m = re.search(r'[A-Z].+(?=/)', abspath)
241+
if m:
242+
snip.rv = m.group().replace('/', '\\')
243+
`;
244+
245+
use Symfony\Component\EventDispatcher\Event;
246+
247+
/**
248+
* ${2:@author `whoami`}
249+
*/
250+
class `!p
251+
snip.rv = re.match(r'.*(?=\.)', fn).group()
252+
` extends Event
253+
{
254+
}
255+
endsnippet
256+
257+
snippet redir "Symfony2 redirect"
258+
$this->redirect($this->generateUrl('${1}', ${2}));
259+
endsnippet

UltiSnips/twig.snippets

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
snippet bl "twig block" b
2+
{% block ${1} %}
3+
${2}
4+
{% endblock $1 %}
5+
endsnippet
6+
7+
snippet js "twig javascripts" b
8+
{% javascripts '${1}' %}
9+
<script src="{{ asset_url }}"></script>
10+
{% endjavascripts %}
11+
endsnippet
12+
13+
snippet css "twig stylesheets" b
14+
{% stylesheets '${1}' %}
15+
<script src="{{ asset_url }}"></script>
16+
{% endstylesheets %}
17+
endsnippet
18+
19+
snippet if "twig if" b
20+
{% if ${1} %}
21+
${2}
22+
{% endif %}
23+
endsnippet
24+
25+
snippet for "twig for" b
26+
{% for ${1} in ${2} %}
27+
${3}
28+
{% endfor %}
29+
endsnippet
30+
31+
snippet ext "twig extends" b
32+
{% extends ${1} %}
33+
endsnippet

0 commit comments

Comments
 (0)