{"id":7347,"date":"2014-05-22T07:54:00","date_gmt":"2014-05-22T15:54:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=7347"},"modified":"2014-11-04T12:08:41","modified_gmt":"2014-11-04T20:08:41","slug":"powershell-studio-2014-file-templates","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/05\/22\/powershell-studio-2014-file-templates\/","title":{"rendered":"PowerShell Studio 2014: File Templates"},"content":{"rendered":"<p>PowerShell Studio always contained templates for various file types. In previous versions, users who wanted to change the template had to manually edit the existing template files. Unfortunately whenever the user updated the application the installer would uninstall the application before applying an update, thus losing any modification made to the template. As a result, we added a new <em>Create Template<\/em> feature to PowerShell Studio 2014 that not only makes it easier to create templates but also preserves them after application updates.<\/p>\n<p><strong>Creating a Template<\/strong><\/p>\n<p>To create a template you can create a new file or simply open an existing template or file. Then use the <em>Create Template<\/em> option in the Ribbon\u2019s file menu:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image_thumb.png\" width=\"244\" height=\"160\"><\/a><\/p>\n<p>Then you are asked to save the file template:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image1.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image_thumb1.png\" width=\"244\" height=\"159\"><\/a><\/p>\n<p>Template files are simple text files that are located in the following user folder:<\/p>\n<blockquote>\n<p>C:\\Users\\&lt;username&gt;\\AppData\\Roaming\\SAPIEN\\PowerShell Studio 2014\\FileTypes<\/p>\n<\/blockquote>\n<p>The file must have the same extension as the file type you wish the template to be applied to.<\/p>\n<p>For Example, a file named UserTemplate.ps1 will only apply to .ps1 script files.<\/p>\n<p><strong>GUI Templates<\/strong><\/p>\n<p>If you are using a GUI form (psf file), it will take you to the usual GUI template dialog instead:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image2.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image_thumb2.png\" width=\"244\" height=\"136\"><\/a><\/p>\n<p>GUI forms are handled differently and require additional information when creating a template.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Template Variables<\/strong><\/p>\n<p>PowerShell Studio supports the following template variables that automatically expand when a template is loaded:<\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"625\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"160\"><strong>Variable<\/strong><\/td>\n<td valign=\"top\" width=\"463\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%AppName%<\/td>\n<td valign=\"top\" width=\"463\">PowerShell Studio name<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%AppVersion%<\/td>\n<td valign=\"top\" width=\"463\">PowerShell Studio version<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%Username%<\/td>\n<td valign=\"top\" width=\"463\">The user name specified in the settings.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%Company%<\/td>\n<td valign=\"top\" width=\"463\">The user company name specified in the settings.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%Year%<\/td>\n<td valign=\"top\" width=\"463\">Current Year i.e. 2014<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%Date%<\/td>\n<td valign=\"top\" width=\"463\">Current Date i.e. 5\/12\/2014<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%Time%<\/td>\n<td valign=\"top\" width=\"463\">Current Time i.e. 2:17 PM<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%FileName%<\/td>\n<td valign=\"top\" width=\"463\">Inserts the file\u2019s name. This will be empty for new non-project files.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%ProjectName%<\/td>\n<td valign=\"top\" width=\"463\">Inserts the file\u2019s project name.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"160\">%GUID%<\/td>\n<td valign=\"top\" width=\"463\">Inserts a unique GUID.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>Multiple Templates<\/strong><\/p>\n<p>In addition to preserving your changes, PowerShell Studio 2014 allows you to define more then one template per file type, where as in the previous versions you could only modify the preset template. For instance, a user who works as a contractor may require unique templates for specific clients. Now the user can create dedicated templates for each of his clients and every time a new file is opened, the user will be presented with a list of available templates:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image3.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/05\/image_thumb3.png\" width=\"244\" height=\"212\"><\/a><\/p>\n<p>Note: The template list will only appear if there is more then one template defined for a specific file type.<\/p>\n<p>&nbsp;<\/p>\n<p>PowerShell Studio 2014\u2019s new <em>Create Template <\/em>option is another new feature that makes it easier for you to customize the IDE to fit your specific needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PowerShell Studio always contained templates for various file types. In previous versions, users who wanted to change the template had to manually edit the existing template files. Unfortunately whenever the user updated the application the installer would uninstall the application before applying an update, thus losing any modification made to the template. As a result, [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,632],"tags":[28,874,81],"class_list":["post-7347","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-whats-new-software-news","tag-powershell","tag-powershell-studio-2014","tag-templates"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=7347"}],"version-history":[{"count":14,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7347\/revisions"}],"predecessor-version":[{"id":8084,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7347\/revisions\/8084"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=7347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=7347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=7347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}