Skip to content
pulse00 edited this page Dec 6, 2011 · 2 revisions

Code Templates

You can contribute eclipse code templates by adding them to the file

https://github.com/pulse00/Twig-Eclipse-Plugin/blob/master/org.eclipse.twig.ui/templates/twigdefault-templates.xml

A template is an XML node in the form

<template
	name="templateName"
	description="%CodeTemplates.descriptionString"
	id="org.eclipse.twig.ui.editor.templates.function.templateID"
	context="twig"
	enabled="true"
	autoinsert="false">%template.templateCode
</template>

Where %CodeTemplates.descriptionString (the description in the UI) and %template.templateCode (the actual code template) are unique externalized strings. They reference the internationalization file in

https://github.com/pulse00/Twig-Eclipse-Plugin/blob/master/org.eclipse.twig.ui/templates/twigdefault-templates.properties

The line

template.templateCode={% for ${item} in ${items} %}\n ${cursor}\n{% endfor %}

will produce

{% for item in items %}
	 
{% endfor %}

where item and items are 2 parameters which will be "tabbable" code blocks. After the 2 params have been altered, the curser will be in the position of ${cursor}.

Clone this wiki locally