A common question among developers is how to surround the current selection in the editor with a parent statement. For example if you start coding a statement that validates an expression and then want to iterate over an array of expressions and do the same to all its elements.
For this end Eclipse templates provide two variables "line_selection" and "word_selection" that help you build custom selection-based wrappers.
In this example three new templates were added to simplify this scenario:

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<templates> | |
<template autoinsert="true" context="php" deleted="false" description="for-each statement wrapper" enabled="true" name="foreachify">foreach (${dollar}${array_expression} as ${dollar}${value}) { | |
${word_selection}${cursor}; | |
} | |
</template> | |
<template autoinsert="true" context="php" deleted="false" description="for statement wrapper" enabled="true" name="forify">for (${dollar}${index} = 0; ${dollar}${index} < ${number_variable}; ${dollar}${index}++) { | |
${word_selection}${cursor}; | |
} | |
</template> | |
<template autoinsert="true" context="php" deleted="false" description="if statement wrapper" enabled="true" name="ifify">if (${word_selection}) { | |
${cursor}; | |
} | |
</template> | |
</templates> |