Setting up an Includes Template for Javascript/Other extensions
I am trying to setup a custom template within File and Code Templates, but not just for PHP but for JS and other files.
There was one that I use for PHP Function Doc Comment that I wanted to also use on Javascript Functions. However, when I created a new one, copied in the syntax, and changed the extension to js, it does not seem to work. When I type /** and hit tab above a php function, it autocompletes to the items below, but not the same when I do it in a JS file.
Do these templates only work for php?
PHP Function Doc Comment (this works, but the same thing will not work for JS)
/**
* Function Name: ${NAME}
* Description:
* Version: 1.0
* Author: {USER}
* Author URI: {USER_URL}
* @package ${PROJECT_NAME}
*
${PARAM_DOC}
#if (${TYPE_HINT} != "void") * @return ${TYPE_HINT}
#end
* ${THROWS_DOC}
*/
Please sign in to leave a comment.
what does your main template look like? Include templates just allow including a certain code snippet into main template, nothing more... To do this, you need specifying #parse("<template_name>.<extension>") in your main template
Elena, this is what my JavaScript file template is shown below. When I open a new file, I get the above there, but it's not a triggered event (like when I am a line above a PHP function, typing in /** will autocomplete what's in the OP).
#parse("JS Function Doc Comment.js")
/*global
alert, confirm, console, prompt
*/
So you are looking for a template for JSDoc comment generation, applied on typing `/**`? This can't be done with include templates, this action for javascript is hardcoded and not template-based;if you miss a possibility to customize the generated comments, please feel free to vote for https://youtrack.jetbrains.com/issue/WEB-13992 and linked tickets.
templates like yours can only be used for new files creation (via File | New | <your main template name>)