Quantcast
Channel: THOMAS.DEULING.ORG » WORKING
Viewing all articles
Browse latest Browse all 5

Best way to add or edit Code snippets and templates in Aptana Studio 3

$
0
0

This post is created with and for Ubuntu-Linux installations. It is a continuation and improvement of this post.

By starting up Aptana Studio 3, the system creates a folder in the users home directory like:

~/Documents/Aptana Rubles

 
After the first start of Aptana Studio 3 these directory is empty.

Now, if you’re currently progamming a PHP-File. The file is opened with the Editor and have the focus. At this moment you are able to use the default snippets and templates. To create your own, just click in the navigation under ‘Commands’ -> ‘PHP’ -> ‘Edit this bundle’.

It seems as it’s nothing happens, but without a noise aptana has created a project names ‘PHP’ in your Project-Explorer. The files from these Project are located in the directory:

~/Documents/Aptana Rubles/php.ruble

 
The result is now a ‘php.ruble’ directory, that’s contains your personalized ‘bundle.rb’.
To create now your own code snippets or templates, you just need to open the PHP-Project from your Project-Exporer and edit the ‘bundle.rb’.
Here you will find a little How-To for creating some snippets.

Here some other snippets, ready to use: ;)

#
# Trigger: foreach
#
# PHP foreach template
#
# if(!empty(array_name))
# foreach(array_name as array_entry) {
#   code to do...
# }
#
snippet "PHP foreach template" do |snip|
  snip.trigger = "foreach"
  snip.expansion  = "if(!empty(${1:array_name}))\n"
  snip.expansion += "foreach(${1:array_name} as ${2:array_entry}) {\n"
  snip.expansion += "\t${3:code to do...}\n"
  snip.expansion += "}\n"
end



#
# Trigger: var_dump_pre
#
# PHP var_dump mit <pre>
#
# echo "<pre>";
# var_dump(var_to_dump);
# echo "</pre>";
#
snippet "PHP var_dump mit <pre>" do |snip|
  snip.trigger = "var_dump_pre"
  snip.expansion  = "echo \"<pre>\";\n"
  snip.expansion += "var_dump(${1:var_to_dump});\n"
  snip.expansion += "echo \"</pre>\";\n"
end



#
# Trigger: doc_func
#
# PHP-Doc Function
#
snippet "PHP-Doc Function" do |snip|
  snip.trigger = "doc_func"  
  snip.expansion  = "/**\n"
  snip.expansion += " * ${1:description}\n"
  snip.expansion += " *\n"
  snip.expansion += " * @author     Thomas Deuling <tdeuling@iscope.de>\n"
  snip.expansion += " * @param      ${2:type} ${3:name} ${4:description}\n"
  snip.expansion += " * @return     ${5:void} ${6:returnDescription}\n"
  snip.expansion += " * @global     ${7:array} ${8:Config-Array}\n"
  snip.expansion += " * @uses       ${9:checkField::checkEmail()}\n"
  snip.expansion += " */"
end



#
# Trigger: doc_file
# PHP-Doc File
#
# /**
# * description
# *
# * @author     Thomas Deuling <tdeuling@iscope.de>
# * @package    default
# *
# * @property   type varname description
# *
# */
#
snippet "PHP-Doc File" do |snip|
  snip.trigger = "doc_file"  
  snip.expansion  = "/**\n"
  snip.expansion += " * ${1:description}\n"
  snip.expansion += " *\n"
  snip.expansion += " * @author     Thomas Deuling <tdeuling@iscope.de>\n"
  snip.expansion += " * @package    ${2:default}\n"
  snip.expansion += " *\n"
  snip.expansion += " * @property   ${3:type} ${4:varname} ${5:description}\n"
  snip.expansion += " *\n"
  snip.expansion += " */"
end

 
Snippet-Collection Download: Aptana Studio 3 - PHP-Snippets (1399)


Viewing all articles
Browse latest Browse all 5

Trending Articles