Search code examples
intellij-ideaidephpstormwebstorm

How to create multi-file template in PhpStorm (or WebStorm)?


I need 2 files for creating new component in React:

${NAME}.js

import React from 'react';
import css from './${NAME}.css';
const ${NAME} = () => (
  <div></div>
);
export default ${NAME};

${NAME}.css

/* Empty */

Note: ${NAME} needs to be entered like constant while creating these files.

I would like to use PhpStorm (or WebStorm) file template feature (or some other simple way) to create both files - by only clicking to create component like on image below:

Example

Is something like that possible ?


Solution

  • As far as I'm aware it's not possible right now unless you code a plugin for that yourself.

    https://youtrack.jetbrains.com/issue/IDEA-91565 -- watch this ticket (star/vote/comment) to get notified on any progress.

    UPDATE 2020-12-04: The aforementioned ticket has been fixed and multi-file templates are available since 2020.3 version.


    Some links if you are thinking about coding it yourself: