darnocian 87 Posted January 3 (edited) I am pleased to announce that Daniele Teti's DelphiMVCFramework (https://github.com/danieleteti/delphimvcframework) now includes an adaptor to integrate with the Sempare Template Engine (https://github.com/sempare/sempare-delphi-template-engine). A sample project (https://github.com/danieleteti/delphimvcframework/tree/master/samples/serversideviews_sempare), modelled on the Mustache sample, illustrates the usage. The README.md provides an overview on the usage and the sample app. Daniele has also published a post on his latest release: https://www.danieleteti.it/post/delphimvcframework-3-4-1-sodium/ The template engine is not included in the distribution. To include it, contrib/get-sempate-template-engine.bat will clone it into the lib folder. The Sempare Template Engine is also available via Embarcadero's GetIt (https://getitnow.embarcadero.com/sempare-template-engine-for-delphi). v1.7.3 and above is required. Note that the template engine is dual-licensed, under GPL for open source and the Sempare Commerical license for commercial projects. Here is an example of how the template engine is used in a project: 1. You need a controller method mapping onto an HTTP endpoint (GET /people) 1 [MVCPath('/people')] 2 [MVCHTTPMethods([httpGET])] 3 [MVCProduces(TMVCMediaType.TEXT_HTML)] 4 5 procedure TWebSiteController.PeopleList; 6 var 7 LDAL: IPeopleDAL; 7 lPeople: TPeople; 9 begin 10 LDAL := TServicesFactory.GetPeopleDAL; 11 lPeople := LDAL.GetPeople; 12 try 13 ViewData['people'] := lPeople; 14 LoadView(['people_list']); 15 RenderResponseStream; 16 finally 17 lPeople.Free; 18 end; 19 end; 2. You need to assign some data to be rendered in the ViewData collection. This could be any data that can be inspected via RTTI. 13 ViewData['people'] := lPeople; 3. Identify the view to be used. 14 LoadView(['people_list']); 4. Define the template 'people_list.tpl' in the 'templates' directory. {{ for person of people }} {{ person.FirstName }} {{ end }} The actual example in the sample project is a bit more detailed. In DAL.pas, type TPerson = class // ... property FirstName: string read FFirstName write SetFirstName; property LastName: string read FLastName write SetLastName; // ... end; The template engine can dereference properties or fields on PODOs, or any type of structure dynamically and provides extensibility methods to support custom behaviour, as required. More detailed documentation is available on https://github.com/sempare/sempare-delphi-template-engine. Please contact us for consulting/support/training if required. info@sempare.ltd/conrad.vermeulen@gmail.com Have fun. Edited January 3 by darnocian 2 Share this post Link to post