From 3f90dcdd7dc69ae593bae8f46617e39d4cb6f158 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 16 Dec 2015 22:26:55 +0100 Subject: [PATCH] Add some twig-mode snippets --- emacs/.emacs.d/snippets/twig-mode/_self | 5 +++++ emacs/.emacs.d/snippets/twig-mode/def | 7 +++++++ emacs/.emacs.d/snippets/twig-mode/for | 7 +++++++ emacs/.emacs.d/snippets/twig-mode/iif | 5 +++++ emacs/.emacs.d/snippets/twig-mode/imp | 7 +++++++ emacs/.emacs.d/snippets/twig-mode/set | 5 +++++ 6 files changed, 36 insertions(+) create mode 100644 emacs/.emacs.d/snippets/twig-mode/_self create mode 100644 emacs/.emacs.d/snippets/twig-mode/def create mode 100644 emacs/.emacs.d/snippets/twig-mode/for create mode 100644 emacs/.emacs.d/snippets/twig-mode/iif create mode 100644 emacs/.emacs.d/snippets/twig-mode/imp create mode 100644 emacs/.emacs.d/snippets/twig-mode/set diff --git a/emacs/.emacs.d/snippets/twig-mode/_self b/emacs/.emacs.d/snippets/twig-mode/_self new file mode 100644 index 0000000..c441690 --- /dev/null +++ b/emacs/.emacs.d/snippets/twig-mode/_self @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: _self +# key: _self +# -- +{% import _self as ${1:`(file-name-nondirectory (file-name-sans-extension buffer-file-name))`} %} \ No newline at end of file diff --git a/emacs/.emacs.d/snippets/twig-mode/def b/emacs/.emacs.d/snippets/twig-mode/def new file mode 100644 index 0000000..78dead4 --- /dev/null +++ b/emacs/.emacs.d/snippets/twig-mode/def @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: default value +# key: def +# -- +{% if $1 is not defined %} + {% set $1 = $2 %} +{% endif %} \ No newline at end of file diff --git a/emacs/.emacs.d/snippets/twig-mode/for b/emacs/.emacs.d/snippets/twig-mode/for new file mode 100644 index 0000000..01c0cc5 --- /dev/null +++ b/emacs/.emacs.d/snippets/twig-mode/for @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: for +# key: for +# -- +{% for $1 in $2 %} + `yas-selected-text`$0 +{% endfor %} \ No newline at end of file diff --git a/emacs/.emacs.d/snippets/twig-mode/iif b/emacs/.emacs.d/snippets/twig-mode/iif new file mode 100644 index 0000000..df26b61 --- /dev/null +++ b/emacs/.emacs.d/snippets/twig-mode/iif @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: Inline if +# key: iif +# -- +{% if $1 %}$0{% endif %} \ No newline at end of file diff --git a/emacs/.emacs.d/snippets/twig-mode/imp b/emacs/.emacs.d/snippets/twig-mode/imp new file mode 100644 index 0000000..01ceb69 --- /dev/null +++ b/emacs/.emacs.d/snippets/twig-mode/imp @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: import +# key: imp +# -- +{% import "${1:module}" as ${1:$(if (string-match "/\\\\([^/]*\\\\)$" yas-text) + (match-string 1 yas-text) + yas-text)} %} \ No newline at end of file diff --git a/emacs/.emacs.d/snippets/twig-mode/set b/emacs/.emacs.d/snippets/twig-mode/set new file mode 100644 index 0000000..715c828 --- /dev/null +++ b/emacs/.emacs.d/snippets/twig-mode/set @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: set +# key: set +# -- +{% set $1 = $2 %} \ No newline at end of file