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
- No additional learning curve.
- One Language.
- Reduce repetitive coding.
- Generate your code in less time with fewer bugs
- Produce consistent code that adheres to your standards.
- 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
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
-
Replace the file extension from template-filetye to php.
-
Executes the new file.php against the PHP executable or parser essential just like running inside a browser.
-
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.