Hello,
I came across this while playing with new customized templates also. I share my experience on Lazarus 2.0.10/deb 11.5.
Start doing menu Tools/Project templates options... -> then enter the directory where you want all yor templates are stored. In my case was preset to "/home/user_tt/.lazarus/templates".
The goal now is to create a templated called Template001.
Then do File/New.../Simple Program.
Edit the program source file in order to customize it, as this will be part of your template, for example I did:
program project1;
{This in TT's template project}
begin
{Initialization}
// ...
{Startup}
// ...
{Master cycle}
// ...
{Finalization}
// ...
end.
Now save the Lazarus project (*.lpi) doing menu Project/Save and make sure file is saved in a subdirectory Template001 of the templates directory. In my case "/home/user_tt/.lazarus/templates/Template001". Choose as file name __ProjName__.lpi (this will automatically update the lpr file name to __ProjName__.lpr and also it will change program name to "program __ProjName__;".
Now open a terminal, go in templates/Template001 directory and do
Leaving file just empty.
Close and restart lazarus, now you should see in menu File and new item "New project from template > <your path to templates/Template001>".
If you click on it the popup in picture Capture appears (maybe you could try different project name and destination directory. Press Ok and you should be done with your new project from template.
Refinements:
Open the project.ini previously created with a text editor and write:
[Project]
Name=Example of Template
Author=SomePerson
[Variables]
MaxNumberOfNetConn=Maximum network connections allowed (integer number 0=no connection, 1-4)
Dimensions=Integer 1-3
Close and restart lazarus, now you should see in menu File and new item "New project from template > Example of Template".
Open the __ProjName.lpr in template folder and modify like this:
program project1;
{This in TT's template project}
const
MaxNumberOfNetConn = __MaxNumberOfNetConn__;
Dimensions = __Dimensions__;
begin
{Initialization}
// ...
{Startup}
// ...
{Master cycle}
// ...
{Finalization}
// ...
end.
Save it.
Close lazarus and restart.
Do File/New project from template > Example of template, you should see that 2 new items appear below, like in picture Capture2 below. Put some values and do ok.
You will see that these values get substituted in the "template variables" present in your source file(s).