Preprocess PHP to any text document using File Watcher In JetBrains Product

There are so many preprocessing or compiling languages,
each with its own learning curve e.g. (scss, sass, jade,typescript ) and the number seems not to be reducing.

Wouldn’t it be cool if developers could execute PHP to produce any text document just like how the above are compiled to native (html, css, js) using file watchers .

Advantages

  1. No additional learning curve.
  2. One Language.
  3. Reduce repetitive coding.
  4. Generate your code in less time with fewer bugs
  5. Produce consistent code that adheres to your standards.
  6. more time focus on planning our application.

WHAT HAVE I TRIED

By editing Jade Source Code and changing the extension from html to php.

File: 		jade.js

Location: 	npm\node_modules\jade\bin\

Line: 		249

I have been able to execute Jade file to PHP

enter image description here

HOW I THINK THIIS CAN BE ACHIEVED

there could be multiple of these transpilers.

template-css → compiles to css

template-php → compiles to php

template-js → compiles to javascript.

and so on.

The Middle Parser or file watcher will do mainly 3 task

  1. Replace the file extension from template-filetye to php.

  2. Executes the new file.php against the PHP executable or parser essential just like running inside a browser.

  3. Return to the file watcher the text specified.

This is the code in the jade.cmd file

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\node_modules\jade\bin\jade.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\node_modules\jade\bin\jade.js" %*
)

Note: I don’t understand the cmd file.
I have not modified this file but taught it might be helpful to any one who wants to help.

Inspiration

http://www.codesmithtools.com/product/generator

Links that MIGHT be helpful

http://php.net/manual/en/function.exec.php

http://php.net/manual/it/install.windows.commandline.php

Any Help in building the filewatcher or whatever the appropriate name is will be greatly appreciated.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.