Extend args.code functionality in extensions system
Posted: Wed Sep 23, 2020 7:42 pm
The args.code feature of the extensions system is incredibly powerful when used in its regex form - as in this simple example:
<# args.code = args.code.replace(/(Config\("PROJECT_STYLESHEET_FILENAME"\))(\) \?>)/gm, '$&<?php echo "?" . filemtime($RELATIVE_PATH . $1) ?>'); #>
By creating a layout.php file containing that single line and adding it to a custom extension, generated applications will always load the latest project CSS without users needing to force a refresh with Ctrl-F5 after CSS changes.
Especially when significant numbers of code changes need to be applied, this avoids the need to manually apply those same code changes to the latest version of each affected file and update the custom extension whenever the PHPM template gets updated... which is almost daily in the weeks following the launch of a new version.
Unfortunately, this great feature can only be applied to "generated" files in the /src, /models and /views folders at present - "copied" files i.e. those in the /js and other folders, cannot be processed this way and means the benefits of easy code replacement via regexes is diminished.
I would therefore like to see the current functionality extended to other files / folders to open up the possibilities for further customisation and tweaks of the PHPM system.
<# args.code = args.code.replace(/(Config\("PROJECT_STYLESHEET_FILENAME"\))(\) \?>)/gm, '$&<?php echo "?" . filemtime($RELATIVE_PATH . $1) ?>'); #>
By creating a layout.php file containing that single line and adding it to a custom extension, generated applications will always load the latest project CSS without users needing to force a refresh with Ctrl-F5 after CSS changes.
Especially when significant numbers of code changes need to be applied, this avoids the need to manually apply those same code changes to the latest version of each affected file and update the custom extension whenever the PHPM template gets updated... which is almost daily in the weeks following the launch of a new version.
Unfortunately, this great feature can only be applied to "generated" files in the /src, /models and /views folders at present - "copied" files i.e. those in the /js and other folders, cannot be processed this way and means the benefits of easy code replacement via regexes is diminished.
I would therefore like to see the current functionality extended to other files / folders to open up the possibilities for further customisation and tweaks of the PHPM system.