├── .gitattributes ├── .gitignore ├── README.md ├── Razor.groupproj ├── demos ├── ClientScript │ ├── ClientMainForm.dfm │ ├── ClientMainForm.pas │ ├── ClientScript.dpr │ ├── ClientScript.dproj │ ├── ClientScript.res │ ├── DataAccessClient_Icon.ico │ └── employee.fds ├── RazorWebBroker │ ├── RazorWebBroker.dpr │ ├── RazorWebBroker.dproj │ ├── RazorWebBroker.res │ ├── RazorWeb_MainForm.dfm │ ├── RazorWeb_MainForm.pas │ ├── RazorWeb_WebModule.dfm │ ├── RazorWeb_WebModule.pas │ └── html │ │ ├── BaseTemplate.html │ │ ├── Company.html │ │ ├── CompanyList.html │ │ ├── GetValue.html │ │ ├── Test.html │ │ ├── Test3.html │ │ ├── Test4.html │ │ ├── TestInclude.html │ │ ├── customer.cds │ │ ├── if.html │ │ └── menu.html └── WBConsole │ ├── ServerConst.pas │ ├── WBConsole.deployproj │ ├── WBConsole.dpr │ ├── WBConsole.dproj │ ├── WBConsole.res │ ├── WebModuleUnit.dfm │ ├── WebModuleUnit.pas │ ├── Win32 │ └── Debug │ │ ├── employee.fds │ │ └── table.html │ ├── employee.fds │ └── table.html ├── source ├── RazorPackage.dpk ├── RazorPackage.dproj ├── RazorPackage.res ├── RazorPackageR102.dpk ├── RazorPackageR102.dproj ├── RazorPackageR102.res ├── RlxCompsRegistration.pas ├── RlxConfiguration.pas ├── RlxLocales.pas ├── RlxRazor.pas └── RlxWebModule.pas └── test ├── RazorTests.dpr ├── RazorTests.dproj ├── RazorTests.res ├── TestRlxRazor.pas ├── UTestRlxRazorEngine.pas └── Win32 └── Debug └── dunit.ini /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | *.dcu 49 | *.local 50 | test/Win32/Debug/RazorTests.exe 51 | *.stat 52 | *.identcache 53 | *.o 54 | *.exe 55 | demos/WBConsole/Linux64/Debug/WBConsole 56 | *.~1~ 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DelphiRazor 2 | The DelphiRazor Web script language engine 3 | 4 | Released under MPL 2.0 license 5 | Copyright Marco Cantu 2016, portions by other contributors (see source code) 6 | -------------------------------------------------------------------------------- /Razor.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1565C4B7-AD56-4674-B666-AA5D8A425B5D} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Default.Personality.12 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /demos/ClientScript/ClientMainForm.dfm: -------------------------------------------------------------------------------- 1 | object DataAccessClientForm: TDataAccessClientForm 2 | Left = 0 3 | Top = 0 4 | Caption = 'ClientScript' 5 | ClientHeight = 636 6 | ClientWidth = 1177 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -20 11 | Font.Name = 'Tahoma' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | PixelsPerInch = 120 15 | TextHeight = 24 16 | object Memo1: TMemo 17 | Left = 21 18 | Top = 26 19 | Width = 681 20 | Height = 87 21 | Margins.Left = 4 22 | Margins.Top = 4 23 | Margins.Right = 4 24 | Margins.Bottom = 4 25 | Lines.Strings = ( 26 | 'Dear @myemp.firstname, the application @form.Caption is ' 27 | 28 | 'telling you that your salary is @myemp.salary and that the answe' + 29 | 'r is ' 30 | '@myclass.value') 31 | TabOrder = 0 32 | end 33 | object DBGrid1: TDBGrid 34 | Left = 21 35 | Top = 323 36 | Width = 681 37 | Height = 284 38 | Margins.Left = 4 39 | Margins.Top = 4 40 | Margins.Right = 4 41 | Margins.Bottom = 4 42 | DataSource = DataSource1 43 | TabOrder = 1 44 | TitleFont.Charset = DEFAULT_CHARSET 45 | TitleFont.Color = clWindowText 46 | TitleFont.Height = -20 47 | TitleFont.Name = 'Tahoma' 48 | TitleFont.Style = [] 49 | end 50 | object MemoLog: TMemo 51 | Left = 719 52 | Top = 323 53 | Width = 409 54 | Height = 284 55 | Margins.Left = 4 56 | Margins.Top = 4 57 | Margins.Right = 4 58 | Margins.Bottom = 4 59 | TabOrder = 2 60 | end 61 | object btnScript: TButton 62 | Left = 719 63 | Top = 27 64 | Width = 129 65 | Height = 34 66 | Caption = 'Script' 67 | TabOrder = 3 68 | OnClick = btnScriptClick 69 | end 70 | object Memo2: TMemo 71 | Left = 24 72 | Top = 128 73 | Width = 678 74 | Height = 97 75 | Lines.Strings = ( 76 | '@foreach (var emp in data) { @emp.firstname - }') 77 | TabOrder = 4 78 | end 79 | object btnScript2: TButton 80 | Left = 719 81 | Top = 128 82 | Width = 129 83 | Height = 36 84 | Caption = 'Script2' 85 | TabOrder = 5 86 | OnClick = btnScript2Click 87 | end 88 | object DataSource1: TDataSource 89 | DataSet = FDMemTable1 90 | Left = 144 91 | Top = 408 92 | end 93 | object FDMemTable1: TFDMemTable 94 | Active = True 95 | FetchOptions.AssignedValues = [evMode] 96 | FetchOptions.Mode = fmAll 97 | ResourceOptions.AssignedValues = [rvPersistent, rvSilentMode] 98 | ResourceOptions.Persistent = True 99 | ResourceOptions.SilentMode = True 100 | UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates] 101 | UpdateOptions.CheckRequired = False 102 | UpdateOptions.AutoCommitUpdates = True 103 | Left = 64 104 | Top = 408 105 | Content = { 106 | 414442530F00B219C20D0000FF00010001FF02FF03040016000000460044004D 107 | 0065006D005400610062006C0065003100050000000000060000070032000000 108 | 080000FF09FF0A04000A00000045006D0070004E006F000B00010000000D000C 109 | 000E00010F000110000111000112000113000114000A00000045006D0070004E 110 | 006F00FEFF0A0400100000004C006100730074004E0061006D0065000B000200 111 | 00000D0015001600140000000E00010F00011000011100011200011300011400 112 | 100000004C006100730074004E0061006D006500170014000000FEFF0A040012 113 | 000000460069007200730074004E0061006D0065000B00030000000D00150016 114 | 000F0000000E00010F0001100001110001120001130001140012000000460069 115 | 007200730074004E0061006D00650017000F000000FEFF0A0400100000005000 116 | 68006F006E0065004500780074000B00040000000D0015001600040000000E00 117 | 010F0001100001110001120001130001140010000000500068006F006E006500 118 | 450078007400170004000000FEFF0A0400100000004800690072006500440061 119 | 00740065000B00050000000D0018000E00010F00011000011100011200011300 120 | 0114001000000048006900720065004400610074006500FEFF0A04000C000000 121 | 530061006C006100720079000B00060000000D0019000E00010F000110000111 122 | 000112000113000114000C000000530061006C00610072007900FEFEFF1AFEFF 123 | 1BFEFF1CFF1D1E0000000000FF1F0000020000000100060000004E656C736F6E 124 | 020007000000526F626572746F03000300000032353004000000EA4F4F87CC42 125 | 0500000000000088E340FEFEFF1D1E0001000000FF1F00000400000001000500 126 | 0000596F756E67020005000000427275636503000300000032333304000000EA 127 | 4F4F87CC420500000000008019EB40FEFEFF1D1E0002000000FF1F0000050000 128 | 000100070000004C616D626572740200030000004B696D030002000000323204 129 | 0000001A4FB687CC42050000000000006AD840FEFEFF1D1E0003000000FF1F00 130 | 00080000000100070000004A6F686E736F6E0200060000004C65736C69650300 131 | 030000003431300400000086A74B88CC420500000000008076D840FEFEFF1D1E 132 | 0004000000FF1F000009000000010006000000466F7265737402000400000050 133 | 68696C03000300000032323904000000AE8D6A88CC420500000000008076D840 134 | FEFEFF1D1E0005000000FF1F00000B000000010006000000576573746F6E0200 135 | 050000004B2E204A2E03000200000033340400000018A82E8BCC420500000000 136 | 009E41E040FEFEFF1D1E0006000000FF1F00000C0000000100030000004C6565 137 | 020005000000546572726903000300000032353604000000C8723A8CCC420500 138 | 000000008022E640FEFEFF1D1E0007000000FF1F00000E000000010004000000 139 | 48616C6C0200070000005374657761727403000300000032323704000000E4FE 140 | 918CCC4205000000000054D6E040FEFEFF1D1E0008000000FF1F00000F000000 141 | 010005000000596F756E670200090000004B6174686572696E65030003000000 142 | 32333104000000B0BEAB8CCC4205000000000000D4D740FEFEFF1D1E00090000 143 | 00FF1F00001400000001000C00000050617061646F706F756C6F730200050000 144 | 004368726973030003000000383837040000003875058BCC4205000000000080 145 | 76D840FEFEFF1D1E000A000000FF1F0000180000000100060000004669736865 146 | 720200040000005065746503000300000038383804000000DC7C938DCC420500 147 | 000000000080D640FEFEFF1D1E000B000000FF1F00001C000000010006000000 148 | 42656E6E6574020003000000416E6E03000100000035040000006020018FCC42 149 | 05009A99999959D6E040FEFEFF1D1E000C000000FF1F00001D00000001000800 150 | 0000446520536F757A61020005000000526F6765720300030000003238380400 151 | 00006EE62C8FCC4205000000000000E7D840FEFEFF1D1E000D000000FF1F0000 152 | 2200000001000700000042616C6477696E0200050000004A616E657403000100 153 | 0000320400000000B97C8FCC4205000000000000C1D640FEFEFF1D1E000E0000 154 | 00FF1F000024000000010006000000526565766573020005000000526F676572 155 | 03000100000036040000004AD8D68FCC42050000000000806AE040FEFEFF1D1E 156 | 000F000000FF1F0000250000000100090000005374616E736275727902000600 157 | 000057696C6C696503000100000037040000004AD8D68FCC4205000000000000 158 | 27E340FEFEFF1D1E0010000000FF1F00002C00000001000500000050686F6E67 159 | 0200060000004C65736C6965030003000000323136040000004C443B90CC4205 160 | 0000000000C0B3E340FEFEFF1D1E0011000000FF1F00002D00000001000A0000 161 | 0052616D616E617468616E0200050000004173686F6B03000300000032303904 162 | 000000E62FD390CC42050048E17A149E41E040FEFEFF1D1E0012000000FF1F00 163 | 002E00000001000800000053746561646D616E02000600000057616C74657203 164 | 00030000003231300400000056C9E790CC42050000000000C023D340FEFEFF1D 165 | 1E0013000000FF1F0000340000000100090000004E6F72647374726F6D020005 166 | 0000004361726F6C030003000000343230040000000AD57291CC420500000000 167 | 000094B140FEFEFF1D1E0014000000FF1F00003D0000000100050000004C6575 168 | 6E670200040000004C756B65030001000000330400000004BFD892CC42050000 169 | 00000080D8E040FEFEFF1D1E0015000000FF1F0000410000000100070000004F 170 | 27427269656E02000800000053756520416E6E65030003000000383737040000 171 | 00204B3093CC42050000000000C08ADE40FEFEFF1D1E0016000000FF1F000047 172 | 00000001000700000042757262616E6B02000B0000004A656E6E69666572204D 173 | 2E0300030000003238390400000042846B93CC420500000000008022E640FEFE 174 | FF1D1E0017000000FF1F00004800000001000A0000005375746865726C616E64 175 | 020007000000436C61756469610400000028647893CC42050000000000606EE1 176 | 40FEFEFF1D1E0018000000FF1F000053000000010006000000426973686F7002 177 | 000400000044616E6103000300000032393004000000B489E493CC4205000000 178 | 000000F9E540FEFEFF1D1E0019000000FF1F0000550000000100090000004D61 179 | 63446F6E616C640200070000004D61727920532E030003000000343737040000 180 | 00B489E493CC42050000000000606EE140FEFEFF1D1E001A000000FF1F00005E 181 | 00000001000800000057696C6C69616D7302000500000052616E647903000300 182 | 000038393204000000ECA19394CC420500000000000039DC40FEFEFF1D1E001B 183 | 000000FF1F00006900000001000600000042656E6465720200090000004F6C69 184 | 76657220482E03000300000032353504000000E2B33095CC42050000000000E0 185 | F7E140FEFEFF1D1E001C000000FF1F00006B000000010004000000436F6F6B02 186 | 00050000004B6576696E03000300000038393404000000BA645B96CC42050000 187 | 0000008055E140FEFEFF1D1E001D000000FF1F00006D00000001000500000042 188 | 726F776E0200050000004B656C6C7903000300000032303204000000441E6396 189 | CC42050000000000005EDA40FEFEFF1D1E001E000000FF1F00006E0000000100 190 | 0600000049636869646102000400000059756B69030002000000323204000000 191 | 441E6396CC420500000000004016D940FEFEFF1D1E001F000000FF1F00007100 192 | 0000010004000000506167650200040000004D61727903000300000038343504 193 | 0000004EA30F97CC420500000000000070E740FEFEFF1D1E0020000000FF1F00 194 | 00720000000100060000005061726B657202000400000042696C6C0300030000 195 | 00323437040000004A629097CC420500000000000017E140FEFEFF1D1E002100 196 | 0000FF1F00007600000001000800000059616D616D6F746F0200070000005461 197 | 6B61736869030002000000323304000000AEA1DD97CC4205000000000000BDDF 198 | 40FEFEFF1D1E0022000000FF1F00007900000001000700000046657272617269 199 | 020007000000526F626572746F0300010000003104000000A8F4F997CC420500 200 | 0000000080C6E340FEFEFF1D1E0023000000FF1F00007F000000010008000000 201 | 59616E6F77736B690200070000004D69636861656C0300030000003439320400 202 | 0000B00D4298CC42050000000000007CE540FEFEFF1D1E0024000000FF1F0000 203 | 86000000010004000000476C6F6E0200070000004A6163717565730400000034 204 | 1A6698CC42050000000000C045D840FEFEFF1D1E0025000000FF1F0000880000 205 | 000100070000004A6F686E736F6E02000500000053636F747403000300000032 206 | 363504000000FA2C9C98CC420500C3F5285C3FDFDD40FEFEFF1D1E0026000000 207 | FF1F00008A000000010005000000477265656E020004000000542E4A2E030003 208 | 00000032313804000000C8581A99CC420500000000000094E140FEFEFF1D1E00 209 | 27000000FF1F00008D0000000100070000004F73626F726E6502000600000050 210 | 6965727265040000001A91BC99CC420500000000000062E140FEFEFF1D1E0028 211 | 000000FF1F00009000000001000A0000004D6F6E74676F6D6572790200040000 212 | 004A6F686E030003000000383230040000008E029A9ACC42050000000000606E 213 | E140FEFEFF1D1E0029000000FF1F00009100000001000C0000004775636B656E 214 | 6865696D65720200040000004D61726B030003000000323231040000007CFBEE 215 | 9ACC420500000000000040DF40FEFEFEFEFEFF20FEFF212200B9000000FF23FE 216 | FEFE0E004D0061006E0061006700650072001E00550070006400610074006500 217 | 73005200650067006900730074007200790012005400610062006C0065004C00 218 | 6900730074000A005400610062006C00650008004E0061006D0065000A005400 219 | 6100620049004400240045006E0066006F0072006300650043006F006E007300 220 | 74007200610069006E00740073001E004D0069006E0069006D0075006D004300 221 | 6100700061006300690074007900180043006800650063006B004E006F007400 222 | 4E0075006C006C00140043006F006C0075006D006E004C006900730074000C00 223 | 43006F006C0075006D006E00100053006F007500720063006500490044000E00 224 | 6400740049006E00740033003200100044006100740061005400790070006500 225 | 1400530065006100720063006800610062006C006500120041006C006C006F00 226 | 77004E0075006C006C000800420061007300650014004F0041006C006C006F00 227 | 77004E0075006C006C0012004F0049006E005500700064006100740065001000 228 | 4F0049006E00570068006500720065001A004F0072006900670069006E004300 229 | 6F006C004E0061006D00650018006400740041006E0073006900530074007200 230 | 69006E0067000800530069007A006500140053006F0075007200630065005300 231 | 69007A0065001400640074004400610074006500540069006D00650010006400 232 | 740044006F00750062006C0065001C0043006F006E0073007400720061006900 233 | 6E0074004C00690073007400100056006900650077004C006900730074000E00 234 | 52006F0077004C00690073007400060052006F0077000A0052006F0077004900 235 | 440010004F0072006900670069006E0061006C001800520065006C0061007400 236 | 69006F006E004C006900730074001C0055007000640061007400650073004A00 237 | 6F00750072006E0061006C001200530061007600650050006F0069006E007400 238 | 0E004300680061006E00670065007300} 239 | end 240 | end 241 | -------------------------------------------------------------------------------- /demos/ClientScript/ClientMainForm.pas: -------------------------------------------------------------------------------- 1 | unit ClientMainForm; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 | Dialogs, StdCtrls, Grids, DBGrids, DB, IniFiles, 8 | FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param, 9 | FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, 10 | FireDAC.Comp.DataSet, FireDAC.Comp.Client, FireDAC.Stan.StorageBin; 11 | 12 | type 13 | TDataAccessClientForm = class(TForm) 14 | Memo1: TMemo; 15 | DataSource1: TDataSource; 16 | DBGrid1: TDBGrid; 17 | MemoLog: TMemo; 18 | btnScript: TButton; 19 | Memo2: TMemo; 20 | btnScript2: TButton; 21 | FDMemTable1: TFDMemTable; 22 | procedure btnScriptClick(Sender: TObject); 23 | procedure btnScript2Click(Sender: TObject); 24 | private 25 | public 26 | { Public declarations } 27 | end; 28 | 29 | var 30 | DataAccessClientForm: TDataAccessClientForm; 31 | 32 | implementation 33 | 34 | {$R *.dfm} 35 | 36 | uses 37 | DateUtils, RlxRazor; 38 | 39 | type 40 | TSimpleClass = class 41 | private 42 | FValue: Integer; 43 | procedure SetValue(const Value: Integer); 44 | published 45 | constructor Create (aValue: Integer); 46 | property Value: Integer read FValue write SetValue; 47 | 48 | end; 49 | 50 | procedure TDataAccessClientForm.btnScript2Click(Sender: TObject); 51 | var 52 | Razor1: TRlxRazorProcessor; 53 | begin 54 | Razor1 := TRlxRazorProcessor.Create(self); 55 | 56 | Razor1.AddToDictionary('data', FDMemTable1, False); 57 | 58 | MemoLog.Lines.Add ( 59 | Razor1.DoBlock (Memo2.Lines.Text)); 60 | 61 | Razor1.Free; 62 | end; 63 | 64 | procedure TDataAccessClientForm.btnScriptClick(Sender: TObject); 65 | var 66 | Razor1: TRlxRazorProcessor; 67 | begin 68 | Razor1 := TRlxRazorProcessor.Create(self); 69 | 70 | Razor1.AddToDictionary('myemp', FDMemTable1, False); 71 | Razor1.AddToDictionary('form', self, False); 72 | Razor1.AddToDictionary('myclass', TSimpleClass.Create(42)); 73 | 74 | MemoLog.Lines.Add ( 75 | Razor1.DoBlock (Memo1.Lines.Text)); 76 | 77 | Razor1.Free; 78 | end; 79 | 80 | { TSimpleClass } 81 | 82 | constructor TSimpleClass.Create(aValue: Integer); 83 | begin 84 | fValue := aValue; 85 | end; 86 | 87 | procedure TSimpleClass.SetValue(const Value: Integer); 88 | begin 89 | FValue := Value; 90 | end; 91 | 92 | end. 93 | -------------------------------------------------------------------------------- /demos/ClientScript/ClientScript.dpr: -------------------------------------------------------------------------------- 1 | program ClientScript; 2 | 3 | uses 4 | Forms, 5 | ClientMainForm in 'ClientMainForm.pas' {DataAccessClientForm}; 6 | 7 | {$R *.res} 8 | 9 | begin 10 | Application.Initialize; 11 | Application.MainFormOnTaskbar := True; 12 | Application.CreateForm(TDataAccessClientForm, DataAccessClientForm); 13 | Application.Run; 14 | end. 15 | -------------------------------------------------------------------------------- /demos/ClientScript/ClientScript.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {941608AC-577B-4D1A-9980-6C3DAB65DA65} 4 | 18.2 5 | ClientScript.dpr 6 | True 7 | Debug 8 | Application 9 | VCL 10 | DCC32 11 | Win32 12 | 1 13 | 14 | 15 | true 16 | 17 | 18 | true 19 | Base 20 | true 21 | 22 | 23 | true 24 | Base 25 | true 26 | 27 | 28 | true 29 | Base 30 | true 31 | 32 | 33 | true 34 | Cfg_1 35 | true 36 | true 37 | 38 | 39 | true 40 | Base 41 | true 42 | 43 | 44 | ClientScript 45 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 46 | Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) 47 | 1033 48 | 00400000 49 | .\$(Config)\$(Platform) 50 | .\$(Config)\$(Platform) 51 | 52 | 53 | true 54 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 55 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 56 | true 57 | DataAccessClient_Icon.ico 58 | System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 59 | 1033 60 | $(BDS)\bin\default_app.manifest 61 | 62 | 63 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 64 | true 65 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 66 | DataAccessClient_Icon.ico 67 | $(BDS)\bin\default_app.manifest 68 | 69 | 70 | DEBUG;$(DCC_Define) 71 | false 72 | true 73 | 74 | 75 | true 76 | Debug 77 | ..\..\source;$(DCC_UnitSearchPath) 78 | true 79 | 80 | 81 | false 82 | RELEASE;$(DCC_Define) 83 | 0 84 | 0 85 | 86 | 87 | 88 | MainSource 89 | 90 | 91 |
DataAccessClientForm
92 |
93 | 94 | Cfg_2 95 | Base 96 | 97 | 98 | Base 99 | 100 | 101 | Cfg_1 102 | Base 103 | 104 |
105 | 106 | 107 | 108 | Delphi.Personality.12 109 | 110 | 111 | 112 | 113 | False 114 | False 115 | 1 116 | 0 117 | 0 118 | 0 119 | False 120 | False 121 | False 122 | False 123 | False 124 | 1033 125 | 1252 126 | 127 | 128 | 129 | 130 | 1.0.0.0 131 | 132 | 133 | 134 | 135 | 136 | 1.0.0.0 137 | 138 | 139 | 140 | Embarcadero C++Builder Office 2000 Servers Package 141 | Embarcadero C++Builder Office XP Servers Package 142 | Microsoft Office 2000 Sample Automation Server Wrapper Components 143 | Microsoft Office XP Sample Automation Server Wrapper Components 144 | 145 | 146 | ClientScript.dpr 147 | 148 | 149 | 150 | True 151 | False 152 | 153 | 154 | 155 | 156 | ClientScript.exe 157 | true 158 | 159 | 160 | 161 | 162 | 1 163 | 164 | 165 | Contents\MacOS 166 | 1 167 | 168 | 169 | Contents\MacOS 170 | 0 171 | 172 | 173 | 174 | 175 | classes 176 | 1 177 | 178 | 179 | 180 | 181 | library\lib\armeabi-v7a 182 | 1 183 | 184 | 185 | 186 | 187 | library\lib\armeabi 188 | 1 189 | 190 | 191 | 192 | 193 | library\lib\mips 194 | 1 195 | 196 | 197 | 198 | 199 | library\lib\armeabi-v7a 200 | 1 201 | 202 | 203 | 204 | 205 | res\drawable 206 | 1 207 | 208 | 209 | 210 | 211 | res\values 212 | 1 213 | 214 | 215 | 216 | 217 | res\drawable 218 | 1 219 | 220 | 221 | 222 | 223 | res\drawable-xxhdpi 224 | 1 225 | 226 | 227 | 228 | 229 | res\drawable-ldpi 230 | 1 231 | 232 | 233 | 234 | 235 | res\drawable-mdpi 236 | 1 237 | 238 | 239 | 240 | 241 | res\drawable-hdpi 242 | 1 243 | 244 | 245 | 246 | 247 | res\drawable-xhdpi 248 | 1 249 | 250 | 251 | 252 | 253 | res\drawable-small 254 | 1 255 | 256 | 257 | 258 | 259 | res\drawable-normal 260 | 1 261 | 262 | 263 | 264 | 265 | res\drawable-large 266 | 1 267 | 268 | 269 | 270 | 271 | res\drawable-xlarge 272 | 1 273 | 274 | 275 | 276 | 277 | 1 278 | 279 | 280 | Contents\MacOS 281 | 1 282 | 283 | 284 | 0 285 | 286 | 287 | 288 | 289 | Contents\MacOS 290 | 1 291 | .framework 292 | 293 | 294 | 0 295 | 296 | 297 | 298 | 299 | 1 300 | .dylib 301 | 302 | 303 | 1 304 | .dylib 305 | 306 | 307 | 1 308 | .dylib 309 | 310 | 311 | Contents\MacOS 312 | 1 313 | .dylib 314 | 315 | 316 | 0 317 | .dll;.bpl 318 | 319 | 320 | 321 | 322 | 1 323 | .dylib 324 | 325 | 326 | 1 327 | .dylib 328 | 329 | 330 | 1 331 | .dylib 332 | 333 | 334 | Contents\MacOS 335 | 1 336 | .dylib 337 | 338 | 339 | 0 340 | .bpl 341 | 342 | 343 | 344 | 345 | 0 346 | 347 | 348 | 0 349 | 350 | 351 | 0 352 | 353 | 354 | 0 355 | 356 | 357 | Contents\Resources\StartUp\ 358 | 0 359 | 360 | 361 | 0 362 | 363 | 364 | 365 | 366 | 1 367 | 368 | 369 | 1 370 | 371 | 372 | 1 373 | 374 | 375 | 376 | 377 | 1 378 | 379 | 380 | 1 381 | 382 | 383 | 1 384 | 385 | 386 | 387 | 388 | 1 389 | 390 | 391 | 1 392 | 393 | 394 | 1 395 | 396 | 397 | 398 | 399 | 1 400 | 401 | 402 | 1 403 | 404 | 405 | 1 406 | 407 | 408 | 409 | 410 | 1 411 | 412 | 413 | 1 414 | 415 | 416 | 1 417 | 418 | 419 | 420 | 421 | 1 422 | 423 | 424 | 1 425 | 426 | 427 | 1 428 | 429 | 430 | 431 | 432 | 1 433 | 434 | 435 | 1 436 | 437 | 438 | 1 439 | 440 | 441 | 442 | 443 | 1 444 | 445 | 446 | 447 | 448 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 449 | 1 450 | 451 | 452 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 453 | 1 454 | 455 | 456 | 457 | 458 | 1 459 | 460 | 461 | 1 462 | 463 | 464 | 465 | 466 | ..\ 467 | 1 468 | 469 | 470 | ..\ 471 | 1 472 | 473 | 474 | 475 | 476 | 1 477 | 478 | 479 | 1 480 | 481 | 482 | 1 483 | 484 | 485 | 486 | 487 | 1 488 | 489 | 490 | 1 491 | 492 | 493 | 1 494 | 495 | 496 | 497 | 498 | ..\ 499 | 1 500 | 501 | 502 | 503 | 504 | Contents 505 | 1 506 | 507 | 508 | 509 | 510 | Contents\Resources 511 | 1 512 | 513 | 514 | 515 | 516 | library\lib\armeabi-v7a 517 | 1 518 | 519 | 520 | 1 521 | 522 | 523 | 1 524 | 525 | 526 | 1 527 | 528 | 529 | 1 530 | 531 | 532 | Contents\MacOS 533 | 1 534 | 535 | 536 | 0 537 | 538 | 539 | 540 | 541 | 1 542 | 543 | 544 | 1 545 | 546 | 547 | 548 | 549 | Assets 550 | 1 551 | 552 | 553 | Assets 554 | 1 555 | 556 | 557 | 558 | 559 | Assets 560 | 1 561 | 562 | 563 | Assets 564 | 1 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 12 578 | 579 | 580 |
581 | -------------------------------------------------------------------------------- /demos/ClientScript/ClientScript.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/ClientScript/ClientScript.res -------------------------------------------------------------------------------- /demos/ClientScript/DataAccessClient_Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/ClientScript/DataAccessClient_Icon.ico -------------------------------------------------------------------------------- /demos/ClientScript/employee.fds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/ClientScript/employee.fds -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWebBroker.dpr: -------------------------------------------------------------------------------- 1 | program RazorWebBroker; 2 | {$APPTYPE GUI} 3 | 4 | uses 5 | Forms, 6 | WebReq, 7 | IdHTTPWebBrokerBridge, 8 | RazorWeb_MainForm in 'RazorWeb_MainForm.pas' {Form12}, 9 | RazorWeb_WebModule in 'RazorWeb_WebModule.pas' {WebModule13: TWebModule}; 10 | 11 | {$R *.res} 12 | 13 | begin 14 | if WebRequestHandler <> nil then 15 | WebRequestHandler.WebModuleClass := WebModuleClass; 16 | Application.Initialize; 17 | Application.CreateForm(TForm12, Form12); 18 | Application.Run; 19 | end. 20 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWebBroker.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {9522EE10-C46F-467F-A470-B76BF6E1988B} 4 | RazorWebBroker.dpr 5 | True 6 | Debug 7 | 1025 8 | Application 9 | VCL 10 | 18.2 11 | Win32 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Cfg_1 34 | true 35 | true 36 | 37 | 38 | true 39 | Base 40 | true 41 | 42 | 43 | true 44 | Cfg_2 45 | true 46 | true 47 | 48 | 49 | true 50 | Cfg_2 51 | true 52 | true 53 | 54 | 55 | RazorWebBroker 56 | false 57 | false 58 | 00400000 59 | Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) 60 | false 61 | 1033 62 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= 63 | false 64 | false 65 | 66 | 67 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(ModuleName) 68 | true 69 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 70 | System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 71 | $(BDS)\bin\default_app.manifest 72 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 73 | 1033 74 | RazorWebBroker_Icon.ico 75 | Debug 76 | true 77 | 78 | 79 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 80 | $(BDS)\bin\default_app.manifest 81 | true 82 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 83 | RazorWebBroker_Icon.ico 84 | 85 | 86 | 0 87 | RELEASE;$(DCC_Define) 88 | false 89 | 0 90 | 91 | 92 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) 93 | true 94 | true 95 | true 96 | 97 | 98 | DEBUG;$(DCC_Define) 99 | true 100 | false 101 | 102 | 103 | Debug 104 | 105 | 106 | $(BDS)\bin\delphi_PROJECTICON.ico 107 | .\$(Platform)\$(Config) 108 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) 109 | .\$(Platform)\$(Config) 110 | ..\..\source;$(DCC_UnitSearchPath) 111 | true 112 | true 113 | true 114 | 115 | 116 | 117 | MainSource 118 | 119 | 120 |
Form12
121 |
122 | 123 |
WebModule13
124 | TWebModule 125 |
126 | 127 | Cfg_2 128 | Base 129 | 130 | 131 | Base 132 | 133 | 134 | Cfg_1 135 | Base 136 | 137 |
138 | 139 | Delphi.Personality.12 140 | 141 | 142 | 143 | 144 | RazorWebBroker.dpr 145 | 146 | 147 | Embarcadero C++Builder Office 2000 Servers Package 148 | Embarcadero C++Builder Office XP Servers Package 149 | Microsoft Office 2000 Sample Automation Server Wrapper Components 150 | Microsoft Office XP Sample Automation Server Wrapper Components 151 | 152 | 153 | 154 | True 155 | True 156 | False 157 | 158 | 159 | 12 160 | 161 | 162 | 163 |
164 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWebBroker.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/RazorWebBroker/RazorWebBroker.res -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWeb_MainForm.dfm: -------------------------------------------------------------------------------- 1 | object Form12: TForm12 2 | Left = 271 3 | Top = 114 4 | Caption = 'RazorWebBroker' 5 | ClientHeight = 235 6 | ClientWidth = 399 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'Tahoma' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | OnCreate = FormCreate 15 | PixelsPerInch = 96 16 | TextHeight = 13 17 | object Label1: TLabel 18 | Left = 24 19 | Top = 48 20 | Width = 20 21 | Height = 13 22 | Caption = 'Port' 23 | end 24 | object ButtonStart: TButton 25 | Left = 24 26 | Top = 8 27 | Width = 75 28 | Height = 25 29 | Caption = 'Start' 30 | TabOrder = 0 31 | OnClick = ButtonStartClick 32 | end 33 | object ButtonStop: TButton 34 | Left = 105 35 | Top = 8 36 | Width = 75 37 | Height = 25 38 | Caption = 'Stop' 39 | TabOrder = 1 40 | OnClick = ButtonStopClick 41 | end 42 | object EditPort: TEdit 43 | Left = 24 44 | Top = 67 45 | Width = 121 46 | Height = 21 47 | TabOrder = 2 48 | Text = '8080' 49 | end 50 | object ButtonOpenBrowser: TButton 51 | Left = 24 52 | Top = 112 53 | Width = 107 54 | Height = 25 55 | Caption = 'Open Browser' 56 | TabOrder = 3 57 | OnClick = ButtonOpenBrowserClick 58 | end 59 | object ApplicationEvents1: TApplicationEvents 60 | OnIdle = ApplicationEvents1Idle 61 | Left = 288 62 | Top = 24 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWeb_MainForm.pas: -------------------------------------------------------------------------------- 1 | unit RazorWeb_MainForm; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 | Dialogs, AppEvnts, StdCtrls, IdHTTPWebBrokerBridge, HTTPApp; 8 | 9 | type 10 | TForm12 = class(TForm) 11 | ButtonStart: TButton; 12 | ButtonStop: TButton; 13 | EditPort: TEdit; 14 | Label1: TLabel; 15 | ApplicationEvents1: TApplicationEvents; 16 | ButtonOpenBrowser: TButton; 17 | procedure FormCreate(Sender: TObject); 18 | procedure ApplicationEvents1Idle(Sender: TObject; var Done: Boolean); 19 | procedure ButtonStartClick(Sender: TObject); 20 | procedure ButtonStopClick(Sender: TObject); 21 | procedure ButtonOpenBrowserClick(Sender: TObject); 22 | private 23 | FServer: TIdHTTPWebBrokerBridge; 24 | procedure StartServer; 25 | { Private declarations } 26 | public 27 | { Public declarations } 28 | end; 29 | 30 | var 31 | Form12: TForm12; 32 | 33 | implementation 34 | 35 | {$R *.dfm} 36 | 37 | uses 38 | ShellApi; 39 | 40 | procedure TForm12.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean); 41 | begin 42 | ButtonStart.Enabled := not FServer.Active; 43 | ButtonStop.Enabled := FServer.Active; 44 | EditPort.Enabled := not FServer.Active; 45 | end; 46 | 47 | procedure TForm12.ButtonOpenBrowserClick(Sender: TObject); 48 | var 49 | LURL: string; 50 | begin 51 | StartServer; 52 | LURL := Format('http://localhost:%s', [EditPort.Text]); 53 | ShellExecute(0, 54 | nil, 55 | PChar(LURL), nil, nil, SW_SHOWNOACTIVATE); 56 | end; 57 | 58 | procedure TForm12.ButtonStartClick(Sender: TObject); 59 | begin 60 | StartServer; 61 | end; 62 | 63 | procedure TForm12.ButtonStopClick(Sender: TObject); 64 | begin 65 | FServer.Active := False; 66 | FServer.Bindings.Clear; 67 | end; 68 | 69 | procedure TForm12.FormCreate(Sender: TObject); 70 | begin 71 | FServer := TIdHTTPWebBrokerBridge.Create(Self); 72 | // start automatically 73 | StartServer; 74 | end; 75 | 76 | procedure TForm12.StartServer; 77 | begin 78 | if not FServer.Active then 79 | begin 80 | FServer.Bindings.Clear; 81 | FServer.DefaultPort := StrToInt(EditPort.Text); 82 | FServer.Active := True; 83 | end; 84 | end; 85 | 86 | end. 87 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWeb_WebModule.dfm: -------------------------------------------------------------------------------- 1 | object WebModule13: TWebModule13 2 | OldCreateOrder = False 3 | OnCreate = WebModuleCreate 4 | Actions = < 5 | item 6 | Name = 'WebActionItem1' 7 | PathInfo = '/test1' 8 | Producer = RlxRazorProcessor1 9 | end 10 | item 11 | Name = 'WebActionItem2' 12 | PathInfo = '/test2' 13 | Producer = RlxRazorProcessor2 14 | end 15 | item 16 | Name = 'WebActionItem3' 17 | PathInfo = '/test3' 18 | OnAction = WebModule13WebActionItem3Action 19 | end 20 | item 21 | Name = 'waValueFromEvent' 22 | PathInfo = '/valuefromevent' 23 | Producer = RlxRazorValueFromEvent 24 | end 25 | item 26 | Name = 'waValueFromObj' 27 | PathInfo = '/valuefromobject' 28 | OnAction = WebModule13WebActionItem5Action 29 | end 30 | item 31 | Name = 'waCompany' 32 | PathInfo = '/company' 33 | OnAction = WebModule13waCompanyAction 34 | end 35 | item 36 | Name = 'waIf' 37 | PathInfo = '/if' 38 | OnAction = WebModule13waIfAction 39 | end 40 | item 41 | Name = 'waCompanyList' 42 | PathInfo = '/list' 43 | OnAction = WebModule13waCompanyListAction 44 | end 45 | item 46 | Default = True 47 | Name = 'DefaultHandler' 48 | PathInfo = '/' 49 | Producer = RlxRazorProcessor1 50 | OnAction = WebModule13DefaultHandlerAction 51 | end> 52 | Height = 449 53 | Width = 602 54 | object RlxRazorProcessor1: TRlxRazorProcessor 55 | InputFilename = '..\..\html\test.html' 56 | OnLang = RlxRazorProcessor1Lang 57 | UserLoggedIn = False 58 | LanguageId = 0 59 | Left = 112 60 | Top = 48 61 | end 62 | object RlxRazorEngine1: TRlxRazorEngine 63 | PathInits = <> 64 | FilesFolder = '..\..\html\' 65 | TemplatesFolder = '..\..\html\' 66 | HomePage = 'test.html' 67 | OnLang = RlxRazorEngine1Lang 68 | Left = 224 69 | Top = 48 70 | end 71 | object RlxRazorProcessor2: TRlxRazorProcessor 72 | InputFilename = '..\..\html\test.html' 73 | RazorEngine = RlxRazorEngine1 74 | UserLoggedIn = False 75 | LanguageId = 0 76 | Left = 288 77 | Top = 112 78 | end 79 | object RlxRazorProcessor3: TRlxRazorProcessor 80 | InputFilename = '..\..\html\test3.html' 81 | RazorEngine = RlxRazorEngine1 82 | UserLoggedIn = False 83 | LanguageId = 0 84 | Left = 288 85 | Top = 176 86 | end 87 | object RlxRazorValueFromEvent: TRlxRazorProcessor 88 | InputFilename = '..\..\html\getvalue.html' 89 | OnValue = RlxRazorValueFromEventValue 90 | UserLoggedIn = False 91 | LanguageId = 0 92 | Left = 96 93 | Top = 136 94 | end 95 | object RlxRazorValueFromObject: TRlxRazorProcessor 96 | InputFilename = '..\..\html\getvalue.html' 97 | OnValue = RlxRazorValueFromEventValue 98 | UserLoggedIn = False 99 | LanguageId = 0 100 | Left = 104 101 | Top = 216 102 | end 103 | object ClientDataSet1: TClientDataSet 104 | Aggregates = <> 105 | FileName = '..\..\html\customer.cds' 106 | Params = <> 107 | Left = 320 108 | Top = 256 109 | end 110 | object RlxRazorValueFromTable: TRlxRazorProcessor 111 | InputFilename = '..\..\html\company.html' 112 | OnValue = RlxRazorValueFromEventValue 113 | UserLoggedIn = False 114 | LanguageId = 0 115 | Left = 104 116 | Top = 288 117 | end 118 | object RlxRazorIf: TRlxRazorProcessor 119 | InputFilename = '..\..\html\if.html' 120 | OnValue = RlxRazorValueFromEventValue 121 | UserLoggedIn = False 122 | LanguageId = 0 123 | Left = 112 124 | Top = 360 125 | end 126 | object RlxRazorCompanyList: TRlxRazorProcessor 127 | InputFilename = '..\..\html\companylist.html' 128 | OnValue = RlxRazorValueFromEventValue 129 | UserLoggedIn = False 130 | LanguageId = 0 131 | Left = 248 132 | Top = 336 133 | end 134 | end 135 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/RazorWeb_WebModule.pas: -------------------------------------------------------------------------------- 1 | unit RazorWeb_WebModule; 2 | 3 | interface 4 | 5 | uses 6 | SysUtils, Classes, HTTPApp, RlxRazor, Generics.Collections, DB, DBClient; 7 | 8 | type 9 | TWebModule13 = class(TWebModule) 10 | RlxRazorProcessor1: TRlxRazorProcessor; 11 | RlxRazorEngine1: TRlxRazorEngine; 12 | RlxRazorProcessor2: TRlxRazorProcessor; 13 | RlxRazorProcessor3: TRlxRazorProcessor; 14 | RlxRazorValueFromEvent: TRlxRazorProcessor; 15 | RlxRazorValueFromObject: TRlxRazorProcessor; 16 | ClientDataSet1: TClientDataSet; 17 | RlxRazorValueFromTable: TRlxRazorProcessor; 18 | RlxRazorIf: TRlxRazorProcessor; 19 | RlxRazorCompanyList: TRlxRazorProcessor; 20 | procedure WebModule13DefaultHandlerAction(Sender: TObject; 21 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 22 | procedure RlxRazorProcessor1Lang(Sender: TObject; const FieldName: string; 23 | var ReplaceText: string); 24 | procedure RlxRazorEngine1Lang(Sender: TObject; const FieldName: string; 25 | var ReplaceText: string); 26 | procedure WebModule13WebActionItem3Action(Sender: TObject; 27 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 28 | procedure WebModuleCreate(Sender: TObject); 29 | procedure RlxRazorValueFromEventValue(Sender: TObject; const ObjectName, 30 | FieldName: string; var ReplaceText: string); 31 | procedure WebModule13WebActionItem5Action(Sender: TObject; 32 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 33 | procedure WebModule13waCompanyAction(Sender: TObject; Request: TWebRequest; 34 | Response: TWebResponse; var Handled: Boolean); 35 | procedure WebModule13waIfAction(Sender: TObject; Request: TWebRequest; 36 | Response: TWebResponse; var Handled: Boolean); 37 | procedure WebModule13waCompanyListAction(Sender: TObject; 38 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 39 | private 40 | { Private declarations } 41 | public 42 | { Public declarations } 43 | end; 44 | 45 | var 46 | WebModuleClass: TComponentClass = TWebModule13; 47 | 48 | implementation 49 | 50 | {$R *.dfm} 51 | 52 | type 53 | TSimpleObject = class 54 | private 55 | FName: string; 56 | FValue: Integer; 57 | procedure SetName(const Value: string); 58 | procedure SetValue(const Value: Integer); 59 | function GetValueBelowTen: Boolean; 60 | public 61 | constructor Create (aName: string; aValue: Integer); 62 | property Name: string read FName write SetName; 63 | property Value: Integer read FValue write SetValue; 64 | property ValueBelowTen: Boolean read GetValueBelowTen; 65 | end; 66 | 67 | procedure TWebModule13.RlxRazorEngine1Lang(Sender: TObject; 68 | const FieldName: string; var ReplaceText: string); 69 | begin 70 | if FieldName = 'hellow' then 71 | ReplaceText := 'Hello World from Engine'; 72 | end; 73 | 74 | procedure TWebModule13.RlxRazorProcessor1Lang(Sender: TObject; 75 | const FieldName: string; var ReplaceText: string); 76 | begin 77 | if FieldName = 'hellow' then 78 | ReplaceText := 'Hello World'; 79 | end; 80 | 81 | procedure TWebModule13.RlxRazorValueFromEventValue(Sender: TObject; 82 | const ObjectName, FieldName: string; var ReplaceText: string); 83 | begin 84 | if SameText (ObjectName, 'data') then 85 | ReplaceText := 'You requested ' + FieldName; 86 | end; 87 | 88 | procedure TWebModule13.WebModule13DefaultHandlerAction(Sender: TObject; 89 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 90 | var 91 | Found: Boolean; 92 | begin 93 | Response.Content := RlxRazorEngine1.ProcessRequest (Request, Found); 94 | Response.ContentType := 'text/html'; 95 | if not Found then 96 | begin 97 | Response.StatusCode := 404; 98 | Response.ReasonString := 'File not found'; 99 | end; 100 | end; 101 | 102 | procedure TWebModule13.WebModule13waCompanyAction(Sender: TObject; 103 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 104 | begin 105 | ClientDataSet1.Open; 106 | RlxRazorValueFromTable.AddToDictionary( 107 | 'dataset', ClientDataSet1, False); // do not destroy 108 | Response.Content := RlxRazorValueFromTable.Content; 109 | ClientDataSet1.Close; 110 | Handled := True; 111 | end; 112 | 113 | procedure TWebModule13.WebModule13waCompanyListAction(Sender: TObject; 114 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 115 | begin 116 | ClientDataSet1.Open; 117 | RlxRazorCompanyList.AddToDictionary( 118 | 'dataset', ClientDataSet1, False); // do not destroy 119 | Response.Content := RlxRazorCompanyList.Content; 120 | ClientDataSet1.Close; 121 | Handled := True; 122 | end; 123 | 124 | procedure TWebModule13.WebModule13waIfAction(Sender: TObject; 125 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 126 | begin 127 | RlxRazorIf.AddToDictionary('obj1', 128 | TSimpleObject.Create ('joe', 55)); 129 | RlxRazorIf.AddToDictionary('obj2', 130 | TSimpleObject.Create ('marc', 9)); 131 | Response.Content := RlxRazorIf.Content; 132 | Handled := True; 133 | end; 134 | 135 | procedure TWebModule13.WebModule13WebActionItem3Action(Sender: TObject; 136 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 137 | begin 138 | Response.Content := RlxRazorProcessor3.Content; 139 | Handled := True; 140 | end; 141 | 142 | procedure TWebModule13.WebModule13WebActionItem5Action(Sender: TObject; 143 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 144 | begin 145 | if not RlxRazorValueFromObject.InDictionary ('data') then 146 | RlxRazorValueFromObject.AddToDictionary('data', 147 | TSimpleObject.Create ('joe', 55)); 148 | Response.Content := RlxRazorValueFromObject.Content; 149 | Handled := True; 150 | end; 151 | 152 | procedure TWebModule13.WebModuleCreate(Sender: TObject); 153 | begin 154 | RlxRazorProcessor3.AddToDictionary ('page', 155 | TSimpleObject.Create ('one', random (100))); 156 | end; 157 | 158 | { TSimpleObject } 159 | 160 | constructor TSimpleObject.Create(aName: string; aValue: Integer); 161 | begin 162 | inherited Create; 163 | fName := aName; 164 | fValue := aValue; 165 | end; 166 | 167 | function TSimpleObject.GetValueBelowTen: Boolean; 168 | begin 169 | Result := FValue < 10; 170 | end; 171 | 172 | procedure TSimpleObject.SetName(const Value: string); 173 | begin 174 | FName := Value; 175 | end; 176 | 177 | procedure TSimpleObject.SetValue(const Value: Integer); 178 | begin 179 | FValue := Value; 180 | end; 181 | 182 | end. 183 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/BaseTemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sample Razor Project 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Sample Razor Project

12 | 13 |
14 | 15 | @RenderBody 16 | 17 |
18 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/Company.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

Company: @dataset.company

4 | 5 |

Company Name is @dataset.company

6 |

Address: @dataset.addr1, @dataset.city

7 |

In: @dataset.state, @dataset.country

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/CompanyList.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

Companies

4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/GetValue.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

GetValue

4 | 5 |

Value obtained with request @@data.name: @data.name

6 |

Value obtained with request @@data.value: @data.value

7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/Test.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

Plain page

4 | 5 |

Query param one is @query.one

6 | 7 |

My translated message is @lang.hellow

8 | 9 |

Import

10 | 11 | @Import TestInclude 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/Test3.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

Page Test3

4 | 5 |

Local data param one is @page.name (the page name)

6 | 7 |

Value is [@page.value]

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/Test4.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

Page Test4

4 | 5 |

Query param one is @query.one

6 | 7 |

My translated message is @lang.hellow

8 | 9 | @if query.first 10 | {

First time here

} 11 | 12 | @foreach 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/TestInclude.html: -------------------------------------------------------------------------------- 1 | 2 |

Plain page

3 | 4 |

Query param one is @query.one

5 | 6 |

My translated message is @lang.hellow

7 | 8 | 9 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/customer.cds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/RazorWebBroker/html/customer.cds -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/if.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

If Test

4 | 5 |

Obj1

6 | 7 | @if obj1.ValueBelowTen { 8 |

@obj1.name has a value of @obj1.value

9 | } 10 | 11 |

Obj2

12 | 13 | @if obj2.ValueBelowTen { 14 |

@obj2.name has a value of @obj2.value

15 | } 16 | 17 |

That's all

18 | 19 | -------------------------------------------------------------------------------- /demos/RazorWebBroker/html/menu.html: -------------------------------------------------------------------------------- 1 | @LayoutPage BaseTemplate 2 | 3 |

Menu

4 | 5 |

Rather emtpy for now

6 | 7 |

That's all

8 | 9 | -------------------------------------------------------------------------------- /demos/WBConsole/ServerConst.pas: -------------------------------------------------------------------------------- 1 | unit ServerConst; 2 | 3 | interface 4 | 5 | resourcestring 6 | sPortInUse = '- Error: Port %s already in use'; 7 | sPortSet = '- Port set to %s'; 8 | sServerRunning = '- The Server is already running'; 9 | sStartingServer = '- Starting HTTP Server on port %d'; 10 | sStoppingServer = '- Stopping Server'; 11 | sServerStopped = '- Server Stopped'; 12 | sServerNotRunning = '- The Server is not running'; 13 | sInvalidCommand = '- Error: Invalid Command'; 14 | sIndyVersion = '- Indy Version: '; 15 | sActive = '- Active: '; 16 | sPort = '- Port: '; 17 | sSessionID = '- Session ID CookieName: '; 18 | sCommands = 'Enter a Command: ' + slineBreak + 19 | ' - "start" to start the server'+ slineBreak + 20 | ' - "stop" to stop the server'+ slineBreak + 21 | ' - "set port" to change the default port'+ slineBreak + 22 | ' - "status" for Server status'+ slineBreak + 23 | ' - "help" to show commands'+ slineBreak + 24 | ' - "exit" to close the application'; 25 | 26 | const 27 | cArrow = '->'; 28 | cCommandStart = 'start'; 29 | cCommandStop = 'stop'; 30 | cCommandStatus = 'status'; 31 | cCommandHelp = 'help'; 32 | cCommandSetPort = 'set port'; 33 | cCommandExit = 'exit'; 34 | 35 | implementation 36 | 37 | end. 38 | -------------------------------------------------------------------------------- /demos/WBConsole/WBConsole.deployproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 12 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | WBConsole\ 13 | WBConsole.exe 14 | ProjectOutput 15 | 0 16 | 17 | 18 | True 19 | True 20 | 21 | 22 | 23 | 24 | WBConsole\ 25 | employee.fds 26 | File 27 | 0 28 | 29 | 30 | True 31 | 32 | 33 | WBConsole\ 34 | WBConsole 35 | ProjectOutput 36 | 1 37 | 38 | 39 | True 40 | True 41 | 42 | 43 | WBConsole\ 44 | table.html 45 | File 46 | 0 47 | 48 | 49 | True 50 | 51 | 52 | 53 | 54 | WBConsole\ 55 | libcgunwind.1.0.dylib 56 | DependencyModule 57 | 1 58 | 59 | 60 | True 61 | 62 | 63 | WBConsole\ 64 | libcgsqlite3.dylib 65 | DependencyModule 66 | 1 67 | 68 | 69 | True 70 | 71 | 72 | 73 | 74 | 75 | WBConsole.app\ 76 | libPCRE.dylib 77 | DependencyModule 78 | 0 79 | 80 | 81 | True 82 | 83 | 84 | WBConsole.app\ 85 | libcgunwind.1.0.dylib 86 | DependencyModule 87 | 0 88 | 89 | 90 | True 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /demos/WBConsole/WBConsole.dpr: -------------------------------------------------------------------------------- 1 | program WBConsole; 2 | {$APPTYPE CONSOLE} 3 | 4 | uses 5 | System.SysUtils, 6 | System.Types, 7 | IPPeerServer, 8 | IPPeerAPI, 9 | IdHTTPWebBrokerBridge, 10 | Web.WebReq, 11 | Web.WebBroker, 12 | WebModuleUnit in 'WebModuleUnit.pas' {WebModule2: TWebModule}, 13 | ServerConst in 'ServerConst.pas'; 14 | 15 | {$R *.res} 16 | 17 | function BindPort(Aport: Integer): Boolean; 18 | var 19 | LTestServer: IIPTestServer; 20 | begin 21 | Result := True; 22 | try 23 | LTestServer := PeerFactory.CreatePeer('', IIPTestServer) as IIPTestServer; 24 | LTestServer.TestOpenPort(APort, nil); 25 | except 26 | Result := False; 27 | end; 28 | end; 29 | 30 | function CheckPort(Aport: Integer): Integer; 31 | begin 32 | if BindPort(Aport) then 33 | Result := Aport 34 | else 35 | Result := 0; 36 | end; 37 | 38 | procedure SetPort(const Aserver: TIdHTTPWebBrokerBridge; APort: String); 39 | begin 40 | if not (Aserver.Active) then 41 | begin 42 | APort := APort.Replace(cCommandSetPort, '').Trim; 43 | if CheckPort(APort.ToInteger) > 0 then 44 | begin 45 | Aserver.DefaultPort := APort.ToInteger; 46 | Writeln(Format(sPortSet, [APort])); 47 | end 48 | else 49 | Writeln(Format(sPortInUse, [Aport])); 50 | end 51 | else 52 | Writeln(sServerRunning); 53 | Write(cArrow); 54 | end; 55 | 56 | procedure StartServer(const Aserver: TIdHTTPWebBrokerBridge); 57 | begin 58 | if not (Aserver.Active) then 59 | begin 60 | if CheckPort(Aserver.DefaultPort) > 0 then 61 | begin 62 | Writeln(Format(sStartingServer, [Aserver.DefaultPort])); 63 | Aserver.Bindings.Clear; 64 | Aserver.Active := True; 65 | end 66 | else 67 | Writeln(Format(sPortInUse, [Aserver.DefaultPort.ToString])); 68 | end 69 | else 70 | Writeln(sServerRunning); 71 | Write(cArrow); 72 | end; 73 | 74 | procedure StopServer(const Aserver: TIdHTTPWebBrokerBridge); 75 | begin 76 | if Aserver.Active then 77 | begin 78 | Writeln(sStoppingServer); 79 | Aserver.Active := False; 80 | Aserver.Bindings.Clear; 81 | Writeln(sServerStopped); 82 | end 83 | else 84 | Writeln(sServerNotRunning); 85 | Write(cArrow); 86 | end; 87 | 88 | procedure WriteCommands; 89 | begin 90 | Writeln(sCommands); 91 | Write(cArrow); 92 | end; 93 | 94 | procedure WriteStatus(const Aserver: TIdHTTPWebBrokerBridge); 95 | begin 96 | Writeln(sIndyVersion + Aserver.SessionList.Version); 97 | Writeln(sActive + Aserver.Active.ToString(TUseBoolStrs.True)); 98 | Writeln(sPort + Aserver.DefaultPort.ToString); 99 | Writeln(sSessionID + Aserver.SessionIDCookieName); 100 | Write(cArrow); 101 | end; 102 | 103 | procedure RunServer(APort: Integer); 104 | var 105 | LServer: TIdHTTPWebBrokerBridge; 106 | LResponse: string; 107 | begin 108 | WriteCommands; 109 | LServer := TIdHTTPWebBrokerBridge.Create(nil); 110 | try 111 | LServer.DefaultPort := APort; 112 | while True do 113 | begin 114 | Readln(LResponse); 115 | LResponse := LowerCase(LResponse); 116 | if LResponse.StartsWith(cCommandSetPort) then 117 | SetPort(LServer, LResponse) 118 | else if sametext(LResponse, cCommandStart) then 119 | StartServer(LServer) 120 | else if sametext(LResponse, cCommandStatus) then 121 | WriteStatus(LServer) 122 | else if sametext(LResponse, cCommandStop) then 123 | StopServer(LServer) 124 | else if sametext(LResponse, cCommandHelp) then 125 | WriteCommands 126 | else if sametext(LResponse, cCommandExit) then 127 | if LServer.Active then 128 | begin 129 | StopServer(LServer); 130 | break 131 | end 132 | else 133 | break 134 | else 135 | begin 136 | Writeln(sInvalidCommand); 137 | Write(cArrow); 138 | end; 139 | end; 140 | finally 141 | LServer.Free; 142 | end; 143 | end; 144 | 145 | begin 146 | try 147 | if WebRequestHandler <> nil then 148 | WebRequestHandler.WebModuleClass := WebModuleClass; 149 | RunServer(8080); 150 | except 151 | on E: Exception do 152 | Writeln(E.ClassName, ': ', E.Message); 153 | end 154 | end. 155 | -------------------------------------------------------------------------------- /demos/WBConsole/WBConsole.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {08B75C95-956E-4DFF-B326-1A914EB41BC4} 4 | 18.2 5 | None 6 | WBConsole.dpr 7 | True 8 | Debug 9 | Linux64 10 | 129 11 | Console 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Cfg_1 39 | true 40 | true 41 | 42 | 43 | true 44 | Cfg_1 45 | true 46 | true 47 | 48 | 49 | true 50 | Base 51 | true 52 | 53 | 54 | .\$(Platform)\$(Config) 55 | .\$(Platform)\$(Config) 56 | false 57 | false 58 | false 59 | false 60 | false 61 | RESTComponents;emsclientfiredac;FireDACIBDriver;emsclient;FireDACCommon;RESTBackendComponents;soapserver;CloudService;FireDACCommonDriver;inet;FireDAC;FireDACSqliteDriver;soaprtl;soapmidas;$(DCC_UsePackage) 62 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 63 | $(BDS)\bin\delphi_PROJECTICON.ico 64 | $(BDS)\bin\delphi_PROJECTICNS.icns 65 | WBConsole 66 | 67 | 68 | FireDACADSDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;inetdb;emsedge;IndyCore;dsnap;DataSnapCommon;DataSnapConnectors;bindengine;FireDACOracleDriver;FireDACMySQLDriver;FireDACCommonODBC;DataSnapClient;RazorPackageR102;IndySystem;FireDACDb2Driver;FireDACInfxDriver;emshosting;FireDACPgDriver;FireDACASADriver;FireDACTDataDriver;DbxCommonDriver;DataSnapServer;xmlrtl;DataSnapNativeClient;rtl;DbxClientDriver;CustomIPTransport;bindcomp;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;dbrtl;IndyProtocols;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 69 | 70 | 71 | DBXSqliteDriver;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;tethering;svnui;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;Intraweb;DBXOracleDriver;inetdb;emsedge;fmx;fmxdae;RadiantShapesFmx;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;DataSnapConnectors;VCLRESTComponents;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;DataSnapClient;RazorPackageR102;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;emshosting;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;DbxCommonDriver;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;dbxcds;VclSmp;adortl;FireDACODBCDriver;RadiantShapesFmx_Design;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 72 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 73 | Debug 74 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 75 | 1033 76 | 77 | 78 | DBXSqliteDriver;fmxase;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;tethering;DataSnapFireDAC;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;Intraweb;DBXOracleDriver;inetdb;emsedge;fmx;fmxdae;RadiantShapesFmx;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;DataSnapConnectors;VCLRESTComponents;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;DataSnapClient;IndyIPCommon;bindcompdbx;vcl;IndyIPServer;DBXSybaseASEDriver;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;emshosting;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;DbxCommonDriver;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;inetdbxpress;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage) 79 | 80 | 81 | DEBUG;$(DCC_Define) 82 | true 83 | false 84 | true 85 | true 86 | true 87 | 88 | 89 | ..\..\source;$(DCC_UnitSearchPath) 90 | /usr/bin/xterm -e "%debuggee%" 91 | (None) 92 | 93 | 94 | false 95 | ..\..\source;$(DCC_UnitSearchPath) 96 | 1033 97 | (None) 98 | 99 | 100 | false 101 | RELEASE;$(DCC_Define) 102 | 0 103 | 0 104 | 105 | 106 | 107 | MainSource 108 | 109 | 110 |
WebModule2
111 | dfm 112 | TWebModule 113 |
114 | 115 | 116 | Cfg_2 117 | Base 118 | 119 | 120 | Base 121 | 122 | 123 | Cfg_1 124 | Base 125 | 126 |
127 | 128 | Delphi.Personality.12 129 | Console 130 | 131 | 132 | 133 | WBConsole.dpr 134 | 135 | 136 | Embarcadero C++Builder Office 2000 Servers Package 137 | Embarcadero C++Builder Office XP Servers Package 138 | Microsoft Office 2000 Sample Automation Server Wrapper Components 139 | Microsoft Office XP Sample Automation Server Wrapper Components 140 | 141 | 142 | 143 | 144 | 145 | true 146 | 147 | 148 | 149 | 150 | true 151 | 152 | 153 | 154 | 155 | true 156 | 157 | 158 | 159 | 160 | true 161 | 162 | 163 | 164 | 165 | WBConsole.exe 166 | true 167 | 168 | 169 | 170 | 171 | WBConsole 172 | true 173 | 174 | 175 | 176 | 177 | 1 178 | 179 | 180 | Contents\MacOS 181 | 0 182 | 183 | 184 | 185 | 186 | classes 187 | 1 188 | 189 | 190 | 191 | 192 | library\lib\armeabi-v7a 193 | 1 194 | 195 | 196 | 197 | 198 | library\lib\armeabi 199 | 1 200 | 201 | 202 | 203 | 204 | library\lib\mips 205 | 1 206 | 207 | 208 | 209 | 210 | library\lib\armeabi-v7a 211 | 1 212 | 213 | 214 | 215 | 216 | res\drawable 217 | 1 218 | 219 | 220 | 221 | 222 | res\values 223 | 1 224 | 225 | 226 | 227 | 228 | res\drawable 229 | 1 230 | 231 | 232 | 233 | 234 | res\drawable-xxhdpi 235 | 1 236 | 237 | 238 | 239 | 240 | res\drawable-ldpi 241 | 1 242 | 243 | 244 | 245 | 246 | res\drawable-mdpi 247 | 1 248 | 249 | 250 | 251 | 252 | res\drawable-hdpi 253 | 1 254 | 255 | 256 | 257 | 258 | res\drawable-xhdpi 259 | 1 260 | 261 | 262 | 263 | 264 | res\drawable-small 265 | 1 266 | 267 | 268 | 269 | 270 | res\drawable-normal 271 | 1 272 | 273 | 274 | 275 | 276 | res\drawable-large 277 | 1 278 | 279 | 280 | 281 | 282 | res\drawable-xlarge 283 | 1 284 | 285 | 286 | 287 | 288 | 1 289 | 290 | 291 | 1 292 | 293 | 294 | 0 295 | 296 | 297 | 298 | 299 | 1 300 | .framework 301 | 302 | 303 | 0 304 | 305 | 306 | 307 | 308 | 1 309 | .dylib 310 | 311 | 312 | 0 313 | .dll;.bpl 314 | 315 | 316 | 317 | 318 | 1 319 | .dylib 320 | 321 | 322 | 1 323 | .dylib 324 | 325 | 326 | 1 327 | .dylib 328 | 329 | 330 | 1 331 | .dylib 332 | 333 | 334 | 0 335 | .bpl 336 | 337 | 338 | 339 | 340 | 0 341 | 342 | 343 | 0 344 | 345 | 346 | 0 347 | 348 | 349 | 0 350 | 351 | 352 | 0 353 | 354 | 355 | 0 356 | 357 | 358 | 359 | 360 | 1 361 | 362 | 363 | 1 364 | 365 | 366 | 1 367 | 368 | 369 | 370 | 371 | 1 372 | 373 | 374 | 1 375 | 376 | 377 | 1 378 | 379 | 380 | 381 | 382 | 1 383 | 384 | 385 | 1 386 | 387 | 388 | 1 389 | 390 | 391 | 392 | 393 | 1 394 | 395 | 396 | 1 397 | 398 | 399 | 1 400 | 401 | 402 | 403 | 404 | 1 405 | 406 | 407 | 1 408 | 409 | 410 | 1 411 | 412 | 413 | 414 | 415 | 1 416 | 417 | 418 | 1 419 | 420 | 421 | 1 422 | 423 | 424 | 425 | 426 | 1 427 | 428 | 429 | 1 430 | 431 | 432 | 1 433 | 434 | 435 | 436 | 437 | 1 438 | 439 | 440 | 441 | 442 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 443 | 1 444 | 445 | 446 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 447 | 1 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 1 456 | 457 | 458 | 1 459 | 460 | 461 | 1 462 | 463 | 464 | 465 | 466 | 467 | 468 | Contents\Resources 469 | 1 470 | 471 | 472 | 473 | 474 | library\lib\armeabi-v7a 475 | 1 476 | 477 | 478 | 1 479 | 480 | 481 | 1 482 | 483 | 484 | 1 485 | 486 | 487 | 1 488 | 489 | 490 | 1 491 | 492 | 493 | 0 494 | 495 | 496 | 497 | 498 | 1 499 | 500 | 501 | 1 502 | 503 | 504 | 505 | 506 | Assets 507 | 1 508 | 509 | 510 | Assets 511 | 1 512 | 513 | 514 | 515 | 516 | Assets 517 | 1 518 | 519 | 520 | Assets 521 | 1 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | True 535 | True 536 | False 537 | 538 | 539 | 12 540 | 541 | 542 | 543 | 544 |
545 | -------------------------------------------------------------------------------- /demos/WBConsole/WBConsole.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/WBConsole/WBConsole.res -------------------------------------------------------------------------------- /demos/WBConsole/WebModuleUnit.dfm: -------------------------------------------------------------------------------- 1 | object WebModule2: TWebModule2 2 | OldCreateOrder = False 3 | Actions = < 4 | item 5 | Default = True 6 | Name = 'DefaultHandler' 7 | PathInfo = '/' 8 | OnAction = WebModule2DefaultHandlerAction 9 | end 10 | item 11 | Name = 'WebActionItem1' 12 | PathInfo = '/table' 13 | OnAction = WebModule2WebActionItem1Action 14 | end> 15 | Height = 230 16 | Width = 415 17 | object RlxRazorProcessor1: TRlxRazorProcessor 18 | InputFilename = './table.html' 19 | UserLoggedIn = False 20 | LanguageId = 0 21 | Left = 120 22 | Top = 120 23 | end 24 | object FDMemTable1: TFDMemTable 25 | FetchOptions.AssignedValues = [evMode] 26 | FetchOptions.Mode = fmAll 27 | ResourceOptions.AssignedValues = [rvPersistent, rvSilentMode] 28 | ResourceOptions.Persistent = True 29 | ResourceOptions.SilentMode = True 30 | UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates] 31 | UpdateOptions.CheckRequired = False 32 | UpdateOptions.AutoCommitUpdates = True 33 | Left = 48 34 | Top = 40 35 | end 36 | object FDStanStorageBinLink1: TFDStanStorageBinLink 37 | Left = 176 38 | Top = 40 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /demos/WBConsole/WebModuleUnit.pas: -------------------------------------------------------------------------------- 1 | unit WebModuleUnit; 2 | 3 | interface 4 | 5 | uses System.SysUtils, System.Classes, Web.HTTPApp, FireDAC.Stan.Intf, 6 | FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, 7 | FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.StorageBin, Data.DB, 8 | FireDAC.Comp.DataSet, FireDAC.Comp.Client, RlxRazor; 9 | 10 | type 11 | TWebModule2 = class(TWebModule) 12 | RlxRazorProcessor1: TRlxRazorProcessor; 13 | FDMemTable1: TFDMemTable; 14 | FDStanStorageBinLink1: TFDStanStorageBinLink; 15 | procedure WebModule2DefaultHandlerAction(Sender: TObject; 16 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 17 | procedure WebModule2WebActionItem1Action(Sender: TObject; 18 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 19 | private 20 | { Private declarations } 21 | public 22 | { Public declarations } 23 | end; 24 | 25 | var 26 | WebModuleClass: TComponentClass = TWebModule2; 27 | 28 | implementation 29 | 30 | {%CLASSGROUP 'System.Classes.TPersistent'} 31 | 32 | {$R *.dfm} 33 | 34 | procedure TWebModule2.WebModule2DefaultHandlerAction(Sender: TObject; 35 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 36 | begin 37 | Response.Content := 38 | '' + 39 | 'Web Server Application' + 40 | 'Web Server Application' + 41 | ''; 42 | end; 43 | 44 | procedure TWebModule2.WebModule2WebActionItem1Action(Sender: TObject; 45 | Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); 46 | var 47 | filename: string; 48 | begin 49 | filename := './employee.fds'; 50 | if not FDMemTable1.Active then 51 | begin 52 | FDMemTable1.LoadFromFile(filename); 53 | FDMemTable1.Open; 54 | end; 55 | 56 | RlxRazorProcessor1.AddToDictionary('employee', FDMemTable1, False); 57 | Response.Content := RlxRazorProcessor1.Content; 58 | end; 59 | 60 | end. 61 | -------------------------------------------------------------------------------- /demos/WBConsole/Win32/Debug/employee.fds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/WBConsole/Win32/Debug/employee.fds -------------------------------------------------------------------------------- /demos/WBConsole/Win32/Debug/table.html: -------------------------------------------------------------------------------- 1 | 2 |

Employees

3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /demos/WBConsole/employee.fds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/demos/WBConsole/employee.fds -------------------------------------------------------------------------------- /demos/WBConsole/table.html: -------------------------------------------------------------------------------- 1 | 2 |

Employees

3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /source/RazorPackage.dpk: -------------------------------------------------------------------------------- 1 | package RazorPackage; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION OFF} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES ON} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DEFINE DEBUG} 27 | {$ENDIF IMPLICITBUILDING} 28 | {$DESCRIPTION 'Delphi Relax Package'} 29 | {$IMPLICITBUILD ON} 30 | 31 | requires 32 | rtl, 33 | dbrtl, 34 | inet; 35 | 36 | contains 37 | RlxRazor in 'RlxRazor.pas', 38 | RlxWebModule in 'RlxWebModule.pas', 39 | RlxConfiguration in 'RlxConfiguration.pas', 40 | RlxCompsRegistration in 'RlxCompsRegistration.pas', 41 | RlxLocales in 'RlxLocales.pas'; 42 | 43 | end. 44 | -------------------------------------------------------------------------------- /source/RazorPackage.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {B55519D2-B956-440F-B794-E616FA97EF1C} 4 | RazorPackage.dpk 5 | 18.2 6 | None 7 | True 8 | Debug 9 | Win32 10 | 1 11 | Package 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Base 39 | true 40 | 41 | 42 | true 43 | Base 44 | true 45 | 46 | 47 | true 48 | Base 49 | true 50 | 51 | 52 | true 53 | Base 54 | true 55 | 56 | 57 | true 58 | Cfg_1 59 | true 60 | true 61 | 62 | 63 | true 64 | Base 65 | true 66 | 67 | 68 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 69 | true 70 | RazorPackage 71 | All 72 | true 73 | .\$(Platform)\$(Config) 74 | .\$(Platform)\$(Config) 75 | false 76 | false 77 | false 78 | false 79 | false 80 | 81 | 82 | None 83 | rtl;dbrtl;inet;$(DCC_UsePackage) 84 | android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services.dex.jar 85 | 86 | 87 | None 88 | rtl;dbrtl;inet;$(DCC_UsePackage) 89 | 90 | 91 | None 92 | rtl;dbrtl;inet;$(DCC_UsePackage) 93 | 94 | 95 | None 96 | rtl;dbrtl;inet;$(DCC_UsePackage) 97 | 98 | 99 | rtl;dbrtl;inet;$(DCC_UsePackage) 100 | 101 | 102 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 103 | rtl;dbrtl;inet;$(DCC_UsePackage) 104 | 1033 105 | CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) 106 | true 107 | 108 | 109 | rtl;dbrtl;inet;$(DCC_UsePackage) 110 | 111 | 112 | DEBUG;$(DCC_Define) 113 | true 114 | false 115 | true 116 | true 117 | true 118 | 119 | 120 | Delphi Relax Package 121 | 1033 122 | true 123 | false 124 | 125 | 126 | false 127 | RELEASE;$(DCC_Define) 128 | 0 129 | 0 130 | 131 | 132 | 133 | MainSource 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | Cfg_2 145 | Base 146 | 147 | 148 | Base 149 | 150 | 151 | Cfg_1 152 | Base 153 | 154 | 155 | 156 | Delphi.Personality.12 157 | Package 158 | 159 | 160 | 161 | RazorPackage.dpk 162 | 163 | 164 | (untitled) 165 | Embarcadero C++Builder Office 2000 Servers Package 166 | Embarcadero C++Builder Office XP Servers Package 167 | Microsoft Office 2000 Sample Automation Server Wrapper Components 168 | Microsoft Office XP Sample Automation Server Wrapper Components 169 | 170 | 171 | 172 | 173 | 174 | RazorPackage.bpl 175 | true 176 | 177 | 178 | 179 | 180 | true 181 | 182 | 183 | 184 | 185 | RazorPackage.bpl 186 | true 187 | 188 | 189 | 190 | 191 | true 192 | 193 | 194 | 195 | 196 | true 197 | 198 | 199 | 200 | 201 | bplRazorPackageR102.so 202 | true 203 | 204 | 205 | 206 | 207 | true 208 | 209 | 210 | 211 | 212 | 1 213 | 214 | 215 | Contents\MacOS 216 | 0 217 | 218 | 219 | 220 | 221 | classes 222 | 1 223 | 224 | 225 | 226 | 227 | library\lib\armeabi-v7a 228 | 1 229 | 230 | 231 | 232 | 233 | library\lib\armeabi 234 | 1 235 | 236 | 237 | 238 | 239 | library\lib\mips 240 | 1 241 | 242 | 243 | 244 | 245 | 246 | library\lib\armeabi-v7a 247 | 1 248 | 249 | 250 | 251 | 252 | res\drawable 253 | 1 254 | 255 | 256 | 257 | 258 | res\values 259 | 1 260 | 261 | 262 | 263 | 264 | res\drawable 265 | 1 266 | 267 | 268 | 269 | 270 | res\drawable-xxhdpi 271 | 1 272 | 273 | 274 | 275 | 276 | res\drawable-ldpi 277 | 1 278 | 279 | 280 | 281 | 282 | res\drawable-mdpi 283 | 1 284 | 285 | 286 | 287 | 288 | res\drawable-hdpi 289 | 1 290 | 291 | 292 | 293 | 294 | res\drawable-xhdpi 295 | 1 296 | 297 | 298 | 299 | 300 | res\drawable-small 301 | 1 302 | 303 | 304 | 305 | 306 | res\drawable-normal 307 | 1 308 | 309 | 310 | 311 | 312 | res\drawable-large 313 | 1 314 | 315 | 316 | 317 | 318 | res\drawable-xlarge 319 | 1 320 | 321 | 322 | 323 | 324 | 1 325 | 326 | 327 | 1 328 | 329 | 330 | 0 331 | 332 | 333 | 334 | 335 | 1 336 | .framework 337 | 338 | 339 | 0 340 | 341 | 342 | 343 | 344 | 1 345 | .dylib 346 | 347 | 348 | 0 349 | .dll;.bpl 350 | 351 | 352 | 353 | 354 | 1 355 | .dylib 356 | 357 | 358 | 1 359 | .dylib 360 | 361 | 362 | 1 363 | .dylib 364 | 365 | 366 | 1 367 | .dylib 368 | 369 | 370 | 0 371 | .bpl 372 | 373 | 374 | 375 | 376 | 0 377 | 378 | 379 | 0 380 | 381 | 382 | 0 383 | 384 | 385 | 0 386 | 387 | 388 | 0 389 | 390 | 391 | 0 392 | 393 | 394 | 395 | 396 | 1 397 | 398 | 399 | 1 400 | 401 | 402 | 1 403 | 404 | 405 | 406 | 407 | 1 408 | 409 | 410 | 1 411 | 412 | 413 | 1 414 | 415 | 416 | 417 | 418 | 1 419 | 420 | 421 | 1 422 | 423 | 424 | 1 425 | 426 | 427 | 428 | 429 | 1 430 | 431 | 432 | 1 433 | 434 | 435 | 1 436 | 437 | 438 | 439 | 440 | 1 441 | 442 | 443 | 1 444 | 445 | 446 | 1 447 | 448 | 449 | 450 | 451 | 1 452 | 453 | 454 | 1 455 | 456 | 457 | 1 458 | 459 | 460 | 461 | 462 | 1 463 | 464 | 465 | 1 466 | 467 | 468 | 1 469 | 470 | 471 | 472 | 473 | 1 474 | 475 | 476 | 477 | 478 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 479 | 1 480 | 481 | 482 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 483 | 1 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 1 492 | 493 | 494 | 1 495 | 496 | 497 | 1 498 | 499 | 500 | 501 | 502 | 503 | 504 | Contents\Resources 505 | 1 506 | 507 | 508 | 509 | 510 | library\lib\armeabi-v7a 511 | 1 512 | 513 | 514 | 1 515 | 516 | 517 | 1 518 | 519 | 520 | 1 521 | 522 | 523 | 1 524 | 525 | 526 | 1 527 | 528 | 529 | 0 530 | 531 | 532 | 533 | 534 | 1 535 | 536 | 537 | 1 538 | 539 | 540 | 541 | 542 | Assets 543 | 1 544 | 545 | 546 | Assets 547 | 1 548 | 549 | 550 | 551 | 552 | Assets 553 | 1 554 | 555 | 556 | Assets 557 | 1 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | False 571 | False 572 | False 573 | False 574 | False 575 | False 576 | True 577 | False 578 | 579 | 580 | 12 581 | 582 | 583 | 584 | 585 | 586 | -------------------------------------------------------------------------------- /source/RazorPackage.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/source/RazorPackage.res -------------------------------------------------------------------------------- /source/RazorPackageR102.dpk: -------------------------------------------------------------------------------- 1 | package RazorPackageR102; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION OFF} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES ON} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DEFINE DEBUG} 27 | {$ENDIF IMPLICITBUILDING} 28 | {$DESCRIPTION 'Delphi Relax Package'} 29 | {$LIBSUFFIX '250'} 30 | {$IMPLICITBUILD ON} 31 | 32 | requires 33 | rtl, 34 | dbrtl, 35 | inet; 36 | 37 | contains 38 | RlxRazor in 'RlxRazor.pas', 39 | RlxWebModule in 'RlxWebModule.pas', 40 | RlxConfiguration in 'RlxConfiguration.pas', 41 | RlxCompsRegistration in 'RlxCompsRegistration.pas', 42 | RlxLocales in 'RlxLocales.pas'; 43 | 44 | end. 45 | -------------------------------------------------------------------------------- /source/RazorPackageR102.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {B55519D2-B956-440F-B794-E616FA97EF1C} 4 | RazorPackageR102.dpk 5 | 18.2 6 | None 7 | True 8 | Debug 9 | Win32 10 | 129 11 | Package 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Base 39 | true 40 | 41 | 42 | true 43 | Base 44 | true 45 | 46 | 47 | true 48 | Base 49 | true 50 | 51 | 52 | true 53 | Base 54 | true 55 | 56 | 57 | true 58 | Cfg_1 59 | true 60 | true 61 | 62 | 63 | true 64 | Base 65 | true 66 | 67 | 68 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 69 | true 70 | RazorPackageR102 71 | All 72 | true 73 | .\$(Platform)\$(Config) 74 | .\$(Platform)\$(Config) 75 | false 76 | false 77 | false 78 | false 79 | false 80 | 81 | 82 | None 83 | rtl;dbrtl;inet;$(DCC_UsePackage) 84 | android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services.dex.jar 85 | 86 | 87 | None 88 | rtl;dbrtl;inet;$(DCC_UsePackage) 89 | 90 | 91 | None 92 | rtl;dbrtl;inet;$(DCC_UsePackage) 93 | 94 | 95 | None 96 | rtl;dbrtl;inet;$(DCC_UsePackage) 97 | 98 | 99 | rtl;dbrtl;inet;$(DCC_UsePackage) 100 | 101 | 102 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 103 | rtl;dbrtl;inet;$(DCC_UsePackage) 104 | 1033 105 | CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) 106 | true 107 | 108 | 109 | rtl;dbrtl;inet;$(DCC_UsePackage) 110 | 111 | 112 | DEBUG;$(DCC_Define) 113 | true 114 | false 115 | true 116 | true 117 | true 118 | 119 | 120 | Delphi Relax Package 121 | 1033 122 | true 123 | false 124 | 250 125 | 126 | 127 | false 128 | RELEASE;$(DCC_Define) 129 | 0 130 | 0 131 | 132 | 133 | 134 | MainSource 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | Cfg_2 146 | Base 147 | 148 | 149 | Base 150 | 151 | 152 | Cfg_1 153 | Base 154 | 155 | 156 | 157 | Delphi.Personality.12 158 | Package 159 | 160 | 161 | 162 | RazorPackageR102.dpk 163 | 164 | 165 | Embarcadero C++Builder Office 2000 Servers Package 166 | Embarcadero C++Builder Office XP Servers Package 167 | Microsoft Office 2000 Sample Automation Server Wrapper Components 168 | Microsoft Office XP Sample Automation Server Wrapper Components 169 | 170 | 171 | 172 | 173 | 174 | true 175 | 176 | 177 | 178 | 179 | true 180 | 181 | 182 | 183 | 184 | true 185 | 186 | 187 | 188 | 189 | RazorPackageR102.bpl 190 | true 191 | 192 | 193 | 194 | 195 | true 196 | 197 | 198 | 199 | 200 | bplRazorPackageR102.so 201 | true 202 | 203 | 204 | 205 | 206 | 1 207 | 208 | 209 | Contents\MacOS 210 | 0 211 | 212 | 213 | 214 | 215 | classes 216 | 1 217 | 218 | 219 | 220 | 221 | library\lib\armeabi-v7a 222 | 1 223 | 224 | 225 | 226 | 227 | library\lib\armeabi 228 | 1 229 | 230 | 231 | 232 | 233 | library\lib\mips 234 | 1 235 | 236 | 237 | 238 | 239 | 240 | library\lib\armeabi-v7a 241 | 1 242 | 243 | 244 | 245 | 246 | res\drawable 247 | 1 248 | 249 | 250 | 251 | 252 | res\values 253 | 1 254 | 255 | 256 | 257 | 258 | res\drawable 259 | 1 260 | 261 | 262 | 263 | 264 | res\drawable-xxhdpi 265 | 1 266 | 267 | 268 | 269 | 270 | res\drawable-ldpi 271 | 1 272 | 273 | 274 | 275 | 276 | res\drawable-mdpi 277 | 1 278 | 279 | 280 | 281 | 282 | res\drawable-hdpi 283 | 1 284 | 285 | 286 | 287 | 288 | res\drawable-xhdpi 289 | 1 290 | 291 | 292 | 293 | 294 | res\drawable-small 295 | 1 296 | 297 | 298 | 299 | 300 | res\drawable-normal 301 | 1 302 | 303 | 304 | 305 | 306 | res\drawable-large 307 | 1 308 | 309 | 310 | 311 | 312 | res\drawable-xlarge 313 | 1 314 | 315 | 316 | 317 | 318 | 1 319 | 320 | 321 | 1 322 | 323 | 324 | 0 325 | 326 | 327 | 328 | 329 | 1 330 | .framework 331 | 332 | 333 | 0 334 | 335 | 336 | 337 | 338 | 1 339 | .dylib 340 | 341 | 342 | 0 343 | .dll;.bpl 344 | 345 | 346 | 347 | 348 | 1 349 | .dylib 350 | 351 | 352 | 1 353 | .dylib 354 | 355 | 356 | 1 357 | .dylib 358 | 359 | 360 | 1 361 | .dylib 362 | 363 | 364 | 0 365 | .bpl 366 | 367 | 368 | 369 | 370 | 0 371 | 372 | 373 | 0 374 | 375 | 376 | 0 377 | 378 | 379 | 0 380 | 381 | 382 | 0 383 | 384 | 385 | 0 386 | 387 | 388 | 389 | 390 | 1 391 | 392 | 393 | 1 394 | 395 | 396 | 1 397 | 398 | 399 | 400 | 401 | 1 402 | 403 | 404 | 1 405 | 406 | 407 | 1 408 | 409 | 410 | 411 | 412 | 1 413 | 414 | 415 | 1 416 | 417 | 418 | 1 419 | 420 | 421 | 422 | 423 | 1 424 | 425 | 426 | 1 427 | 428 | 429 | 1 430 | 431 | 432 | 433 | 434 | 1 435 | 436 | 437 | 1 438 | 439 | 440 | 1 441 | 442 | 443 | 444 | 445 | 1 446 | 447 | 448 | 1 449 | 450 | 451 | 1 452 | 453 | 454 | 455 | 456 | 1 457 | 458 | 459 | 1 460 | 461 | 462 | 1 463 | 464 | 465 | 466 | 467 | 1 468 | 469 | 470 | 471 | 472 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 473 | 1 474 | 475 | 476 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 477 | 1 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 1 486 | 487 | 488 | 1 489 | 490 | 491 | 1 492 | 493 | 494 | 495 | 496 | 497 | 498 | Contents\Resources 499 | 1 500 | 501 | 502 | 503 | 504 | library\lib\armeabi-v7a 505 | 1 506 | 507 | 508 | 1 509 | 510 | 511 | 1 512 | 513 | 514 | 1 515 | 516 | 517 | 1 518 | 519 | 520 | 1 521 | 522 | 523 | 0 524 | 525 | 526 | 527 | 528 | 1 529 | 530 | 531 | 1 532 | 533 | 534 | 535 | 536 | Assets 537 | 1 538 | 539 | 540 | Assets 541 | 1 542 | 543 | 544 | 545 | 546 | Assets 547 | 1 548 | 549 | 550 | Assets 551 | 1 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | False 565 | False 566 | False 567 | False 568 | True 569 | False 570 | True 571 | False 572 | 573 | 574 | 12 575 | 576 | 577 | 578 | 579 | 580 | -------------------------------------------------------------------------------- /source/RazorPackageR102.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/source/RazorPackageR102.res -------------------------------------------------------------------------------- /source/RlxCompsRegistration.pas: -------------------------------------------------------------------------------- 1 | unit RlxCompsRegistration; 2 | 3 | interface 4 | 5 | procedure Register; 6 | 7 | implementation 8 | 9 | uses 10 | Classes, {RlxTableModule, }RlxRazor; 11 | 12 | procedure Register; 13 | begin 14 | RegisterComponents('Razor', [TRlxRazorProcessor, TRlxRazorEngine]); 15 | // RegisterComponents ('Relax', [TRlxQueryGateway, TRlxTableGateway, TRlxTableModule]); 16 | end; 17 | 18 | 19 | end. 20 | -------------------------------------------------------------------------------- /source/RlxConfiguration.pas: -------------------------------------------------------------------------------- 1 | unit RlxConfiguration; 2 | 3 | /////////////////////////////////////////////////////////////////// 4 | /// Delphi Relax: http://code.marcocantu.com/p/delphirelax /// 5 | /// /// 6 | /// Project coordination: Marco Cantu', marco.cantu@gmail.com /// 7 | /// /// 8 | /// Source code available under MPL http://www.mozilla.org/MPL /// 9 | /// /// 10 | /////////////////////////////////////////////////////////////////// 11 | /// /// 12 | /// Contributors to this unit: /// 13 | /// Francesco Fontana, Marco Cantu /// 14 | /// /// 15 | /////////////////////////////////////////////////////////////////// 16 | 17 | interface 18 | 19 | uses 20 | IniFiles, Classes, SysUtils; 21 | 22 | type 23 | TRlxConfiguration = class 24 | private 25 | memIni: TMemIniFile; 26 | fDatabaseParams: TStrings; 27 | function GetValue(const Name: string): string; 28 | public 29 | constructor CreateFromIni (const filename: string); 30 | destructor Destroy; override; 31 | 32 | // read section:value from ini file 33 | property Value[const Name: string]: string read GetValue; default; 34 | procedure ReadSectionValues (const sectionName: string; sList: TStrings); 35 | 36 | function JSONDateTimeFormatString: string; 37 | function DateFormatString: string; 38 | function DateTimeFormatString: string; 39 | end; 40 | 41 | // Warning: Since this is global we might have to figure out if 42 | // it needs thread protection, although is is basically a read-only structure 43 | var 44 | ServerConf: TRlxConfiguration = nil; 45 | 46 | implementation 47 | 48 | { TConfiguration } 49 | 50 | constructor TRlxConfiguration.CreateFromIni(const filename: string); 51 | begin 52 | memIni := TMemIniFile.Create (filename); 53 | fDatabaseParams := TStringList.Create; 54 | end; 55 | 56 | function TRlxConfiguration.DateFormatString: string; 57 | begin 58 | Result := GetValue ('database:DateFormatString'); 59 | if Result = '' then 60 | Result := FormatSettings.ShortDateFormat; 61 | end; 62 | 63 | function TRlxConfiguration.DateTimeFormatString: string; 64 | begin 65 | Result := GetValue ('database:DateTimeFormatString'); 66 | if Result = '' then 67 | Result := FormatSettings.ShortDateFormat + ' ' + FormatSettings.ShortTimeFormat; 68 | end; 69 | 70 | destructor TRlxConfiguration.Destroy; 71 | begin 72 | fDatabaseParams.Free; 73 | memIni.Free; 74 | inherited; 75 | end; 76 | 77 | function TRlxConfiguration.GetValue(const Name: string): string; 78 | var 79 | nPos: Integer; 80 | begin 81 | nPos := Pos (':', Name); 82 | Result := memIni.ReadString( 83 | Copy (Name, 1, nPos -1), 84 | Copy (Name, nPos + 1), ''); 85 | end; 86 | 87 | function TRlxConfiguration.JSONDateTimeFormatString: string; 88 | begin 89 | Result := GetValue ('database:JSONDateTimeFormatString'); 90 | if Result = '' then 91 | Result := FormatSettings.ShortDateFormat; 92 | end; 93 | 94 | procedure TRlxConfiguration.ReadSectionValues(const sectionName: string; 95 | sList: TStrings); 96 | begin 97 | memIni.ReadSectionValues(sectionName, sList); 98 | end; 99 | 100 | initialization 101 | ServerConf := TRlxConfiguration.CreateFromIni( 102 | ChangeFileExt (ParamStr(0), '.ini')); 103 | 104 | 105 | end. 106 | -------------------------------------------------------------------------------- /source/RlxLocales.pas: -------------------------------------------------------------------------------- 1 | unit RlxLocales; 2 | 3 | /////////////////////////////////////////////////////////////////// 4 | /// Delphi Relax: http://code.marcocantu.com/p/delphirelax /// 5 | /// /// 6 | /// Project coordination: Marco Cantu', marco.cantu@gmail.com /// 7 | /// /// 8 | /// Source code available under MPL http://www.mozilla.org/MPL /// 9 | /// /// 10 | /////////////////////////////////////////////////////////////////// 11 | /// /// 12 | /// Contributors to this unit: /// 13 | /// Marco Cantu /// 14 | /// /// 15 | /////////////////////////////////////////////////////////////////// 16 | 17 | interface 18 | 19 | uses 20 | Classes, SysUtils, Generics.Collections; 21 | 22 | // data shared among RlxRazor and other units, to avoid Razor to depend on 23 | // DataSnap and enterprise features 24 | 25 | var 26 | RlxLocaleDictionary: TDictionary ; 27 | 28 | implementation 29 | 30 | initialization 31 | RlxLocaleDictionary := TDictionary .Create; 32 | 33 | finalization 34 | FreeAndNil(RlxLocaleDictionary); 35 | 36 | end. 37 | -------------------------------------------------------------------------------- /source/RlxWebModule.pas: -------------------------------------------------------------------------------- 1 | unit RlxWebModule; 2 | 3 | /////////////////////////////////////////////////////////////////// 4 | /// Delphi Relax: http://code.marcocantu.com/p/delphirelax /// 5 | /// /// 6 | /// Project coordination: Marco Cantu', marco.cantu@gmail.com /// 7 | /// /// 8 | /// Source code available under MPL http://www.mozilla.org/MPL /// 9 | /// /// 10 | /////////////////////////////////////////////////////////////////// 11 | /// /// 12 | /// Contributors to this unit: /// 13 | /// Marco Cantu /// 14 | /// /// 15 | /////////////////////////////////////////////////////////////////// 16 | 17 | interface 18 | 19 | uses 20 | HTTPApp, Classes, RlxRazor, RlxConfiguration; 21 | 22 | // uses a class interceptor to avoid desing time problems in case 23 | // you are not using TWebModule 24 | 25 | type 26 | TWebModule = class (HTTPApp.TWebModule, IWebRequestHandler) 27 | published 28 | // rlxDSHTTPWebDispatcher: TDSHTTPWebDispatcher; 29 | rlxRazorEngine: TRlxRazorEngine; 30 | private 31 | // session related data, re-computed for each incoming request 32 | FSessionID: string; 33 | // FSessionData: TBaseSessionData; 34 | FUtf8Result: Boolean; 35 | 36 | procedure RazorScaffolding(Sender: TObject; const qualifClassName: string; 37 | var ReplaceText: string); 38 | // procedure ReadSessionInfo (Request: TWebRequest; Response: TWebResponse); 39 | procedure SetUtf8Result(const Value: Boolean); 40 | procedure ConvertResponseToUTF8(Response: TWebResponse; 41 | const ResponseContent: String); 42 | protected 43 | // session related properties 44 | property SessionID: string read FSessionID; 45 | // property SessionData: TBaseSessionData read FSessionData; 46 | property Utf8Result: Boolean read FUtf8Result write SetUtf8Result; 47 | public 48 | constructor Create (Owner: TComponent); override; 49 | destructor Destroy; override; 50 | procedure OnRelaxDefaultAction (Sender: TObject; Request: TWebRequest; 51 | Response: TWebResponse; var Handled: Boolean); 52 | public 53 | QueryParams: TStringList; 54 | function HandleRequest(Request: TWebRequest; Response: TWebResponse): Boolean; 55 | end; 56 | 57 | implementation 58 | 59 | uses 60 | {RlxDynamicServerClass,} SysUtils{, RlxWebUI}; 61 | 62 | { TWebModule } 63 | 64 | constructor TWebModule.Create(Owner: TComponent); 65 | var 66 | aWebAction: TWebActionItem; 67 | begin 68 | inherited Create(Owner); 69 | 70 | // // create the HTTP dispatcher, using some global settings 71 | // rlxDSHTTPWebDispatcher := TDSHTTPWebDispatcher.Create(self); 72 | // rlxDSHTTPWebDispatcher.Server := RlxDataSnap.rlxDSServer; 73 | // rlxDSHTTPWebDispatcher.SessionTimeout := TSessionsData.SessionTimeOut; 74 | // rlxDSHTTPWebDispatcher.WebDispatch.MethodType := mtAny; 75 | // rlxDSHTTPWebDispatcher.WebDispatch.PathInfo := 'datasnap*'; 76 | // rlxDSHTTPWebDispatcher.AuthenticationManager := RlxDataSnap.rlxDSAuthenticationManager; 77 | 78 | // create the razor engine 79 | rlxRazorEngine := TRlxRazorEngine.Create(self); 80 | rlxRazorEngine.FilesFolder := ServerConf['razor:files_folder']; 81 | rlxRazorEngine.TemplatesFolder := ServerConf['razor:templates_folder']; 82 | rlxRazorEngine.HomePage := ServerConf['pages:homepage']; 83 | rlxRazorEngine.ErrorPage := ServerConf['pages:errorpage']; 84 | ServerConf.ReadSectionValues('aliases', rlxRazorEngine.Aliases); 85 | rlxRazorEngine.OnScaffolding := RazorScaffolding; 86 | 87 | // install default event handler in Web Module 88 | aWebAction := Actions.Add; 89 | aWebAction.PathInfo := '/relaxdefaultaction'; 90 | aWebAction.Default := True; 91 | aWebAction.OnAction := OnRelaxDefaultAction; 92 | 93 | QueryParams := TStringList.Create; // used by jqGrid and other custom processing 94 | end; 95 | 96 | destructor TWebModule.Destroy; 97 | begin 98 | QueryParams.Free; 99 | inherited; 100 | end; 101 | 102 | //procedure TWebModule.ReadSessionInfo (Request: TWebRequest; Response: TWebResponse); 103 | //begin 104 | // if FSessionID = '' then 105 | // begin 106 | // FSessionID := sessionsData.GetOrCreateSessionID(Request, 107 | // Response, RlxDataSnap.rlxDSAuthenticationManager); 108 | // end; 109 | //end; 110 | 111 | procedure TWebModule.SetUtf8Result(const Value: Boolean); 112 | begin 113 | FUtf8Result := Value; 114 | end; 115 | 116 | function TWebModule.HandleRequest(Request: TWebRequest; 117 | Response: TWebResponse): Boolean; 118 | begin 119 | // reset the data, given the web module is recycled 120 | FSessionID := ''; 121 | // FSessionData := nil; 122 | // initialize session if needed and read sessiond data 123 | // LanguageID and other info used by HTML/JS translations and processing 124 | // ReadSessionInfo (Request, Response); 125 | // FSessionData := SessionsData.Items[FSessionid]; 126 | 127 | // manage params for jqGrid 128 | if Request.QueryFields.Count > 2 then 129 | begin 130 | QueryParams.Assign(Request.QueryFields); 131 | Request.QueryFields.Clear; 132 | end 133 | else 134 | QueryParams.Clear; 135 | 136 | // add sessionid to request so that REST methods will use it 137 | Request.QueryFields.Add('SESSIONID=' + FSessionID); 138 | 139 | Result := inherited HandleRequest (Request, Response); 140 | end; 141 | 142 | procedure TWebModule.ConvertResponseToUTF8(Response: TWebResponse; 143 | const ResponseContent: String); 144 | var 145 | aStream: TMemoryStream; 146 | aStreamWriter: TStreamWriter; 147 | begin 148 | aStream := TMemoryStream.Create; 149 | aStreamWriter := TStreamWriter.Create (aStream, TEncoding.UTF8); 150 | try 151 | aStreamWriter.Write(ResponseContent); 152 | aStream.Position := 0; 153 | Response.ContentType := 'text/html; charset=utf-8'; 154 | Response.ContentStream := aStream; 155 | finally 156 | aStreamWriter.Free; 157 | end; 158 | end; 159 | 160 | 161 | procedure TWebModule.OnRelaxDefaultAction(Sender: TObject; Request: TWebRequest; 162 | Response: TWebResponse; var Handled: Boolean); 163 | var 164 | Found: Boolean; 165 | stringResponse: string; 166 | begin 167 | Found := False; 168 | try 169 | if QueryParams.Count > 0 then 170 | Request.QueryFields.Assign (QueryParams); 171 | 172 | stringResponse := rlxRazorEngine.ProcessRequest(Request, Found, 173 | False {FSessionData.LoggedIn}, 1 {FSessionData.LanguageID}, '', '' {sessionData.Role}); 174 | if Utf8Result then 175 | ConvertResponseToUTF8 (Response, stringResponse) 176 | else 177 | Response.Content := stringResponse; 178 | except 179 | on E: ERlxLoginRequired do 180 | begin 181 | // if Assigned(sessionData) then 182 | // FSessionData.PageBeforeLogin := Trim(string(Request.InternalPathInfo)); // TODO: aggiungere parametri 183 | Response.SendRedirect(ServerConf['pages:loginpage']); 184 | end; 185 | on E: Exception do 186 | begin 187 | Response.StatusCode := 500; 188 | Response.ReasonString := 'Server error'; 189 | end; 190 | end; 191 | if not Found then 192 | begin 193 | Response.StatusCode := 303; 194 | Response.ReasonString := 'Not found'; 195 | end; 196 | end; 197 | 198 | procedure TWebModule.RazorScaffolding(Sender: TObject; 199 | const qualifClassName: string; var ReplaceText: string); 200 | begin 201 | // this is quite a hack, we probably need an extended syntax for this 202 | // if Pos ('View_', qualifClassName) = 1 then 203 | // ReplaceText := HtmlFormForClass(Copy (qualifClassName, 6, maxint), True) 204 | // else 205 | // ReplaceText := HtmlFormForClass(qualifClassName); // form-based HTML 206 | end; 207 | 208 | 209 | initialization 210 | // load some global settings 211 | // TUserManagement.PageAfterLogin := ServerConf['pages:pageafterlogin']; 212 | // TBaseSessionData.GuestUserName := ServerConf['users:guest_username']; 213 | 214 | end. 215 | -------------------------------------------------------------------------------- /test/RazorTests.dpr: -------------------------------------------------------------------------------- 1 | program RazorTests; 2 | { 3 | 4 | Delphi DUnit Test Project 5 | ------------------------- 6 | This project contains the DUnit test framework and the GUI/Console test runners. 7 | Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options 8 | to use the console test runner. Otherwise the GUI test runner will be used by 9 | default. 10 | 11 | } 12 | 13 | {$IFDEF CONSOLE_TESTRUNNER} 14 | {$APPTYPE CONSOLE} 15 | {$ENDIF} 16 | 17 | uses 18 | DUnitTestRunner, 19 | TestRlxRazor in 'TestRlxRazor.pas', 20 | RlxRazor in '..\source\RlxRazor.pas', 21 | UTestRlxRazorEngine in 'UTestRlxRazorEngine.pas'; 22 | 23 | {$R *.RES} 24 | 25 | begin 26 | DUnitTestRunner.RunRegisteredTests; 27 | end. 28 | 29 | -------------------------------------------------------------------------------- /test/RazorTests.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcocantu/DelphiRazor/a0b6e89c29594d9a649be5fe92206514e52119cb/test/RazorTests.res -------------------------------------------------------------------------------- /test/TestRlxRazor.pas: -------------------------------------------------------------------------------- 1 | unit TestRlxRazor; 2 | { 3 | 4 | Delphi DUnit Test Case 5 | ---------------------- 6 | This unit contains a skeleton test case class generated by the Test Case Wizard. 7 | Modify the generated code to correctly setup and call the methods from the unit 8 | being tested. 9 | 10 | } 11 | 12 | interface 13 | 14 | uses 15 | TestFramework, DB, Generics.Collections, CopyPrsr, Classes, Contnrs, SysUtils, HTTPProd, 16 | RlxRazor, HTTPApp; 17 | 18 | type 19 | // Test methods for class TRlxRazorEngine 20 | 21 | TestTRlxRazorEngine = class(TTestCase) 22 | strict private 23 | FRlxRazorEngine: TRlxRazorEngine; 24 | public 25 | procedure SetUp; override; 26 | procedure TearDown; override; 27 | published 28 | procedure TestGetTemplatesFolder; 29 | procedure TestGetOtherValue; 30 | procedure TestGetLang; 31 | procedure TestGetScaffolding; 32 | procedure TestAddWarning; 33 | procedure TestProcessRequest; 34 | procedure TestGetLangFormats; 35 | 36 | // 5. templates 37 | end; 38 | // Test methods for class TRlxRazorProcessor 39 | 40 | TestTRlxRazorProcessor = class(TTestCase) 41 | strict private 42 | FRlxRazorProcessor: TRlxRazorProcessor; 43 | private 44 | procedure TestValueHandler (Sender: TObject; const ObjectName: string; 45 | const FieldName: string; var ReplaceText: string); 46 | procedure RunLoginRequiredScript; 47 | procedure RunLoginPermissionScript; 48 | public 49 | procedure SetUp; override; 50 | procedure TearDown; override; 51 | published 52 | // 1. basic processing 53 | procedure TestDoBlock; 54 | procedure TestDoubleAt; 55 | procedure TestUnicode; 56 | 57 | // 2. values and dictionary 58 | procedure TestValueEvent; 59 | procedure TestAddToDictionary; 60 | procedure TestValueFromDictionary; 61 | // add test for db data access 62 | 63 | // 3. if 64 | procedure TestIfTrue; 65 | procedure TestIfFalse; 66 | procedure TestIfEmptyString; 67 | procedure TestIfNotEmptyString; 68 | // add tests for booelan evaluation of numeric values 69 | 70 | // 4. foreach 71 | procedure TestForIfList; 72 | // add a database foreach test 73 | // add a nested foreach test 74 | 75 | // 5. lang 76 | 77 | // 6. login stuff 78 | procedure TestIsLogged; 79 | procedure TestIsNotLogged; 80 | procedure TestPermission; 81 | procedure TestWrongPermission; 82 | 83 | end; 84 | 85 | implementation 86 | 87 | const 88 | SampleObjectName = 'AnObject'; 89 | SampleFieldName = 'AField'; 90 | SampleFieldValue = 'AValue'; 91 | SampleBoolFieldName = 'ABool'; 92 | 93 | type 94 | TSimpleObj = class 95 | private 96 | FAField: string; 97 | FABool: Boolean; 98 | procedure SetAField(const Value: string); 99 | procedure SetABool(const Value: Boolean); 100 | public 101 | property AField: string read FAField write SetAField; 102 | property ABool: Boolean read FABool write SetABool; 103 | end; 104 | 105 | 106 | 107 | procedure TestTRlxRazorEngine.SetUp; 108 | begin 109 | FRlxRazorEngine := TRlxRazorEngine.Create (nil); 110 | end; 111 | 112 | procedure TestTRlxRazorEngine.TearDown; 113 | begin 114 | FRlxRazorEngine.Free; 115 | FRlxRazorEngine := nil; 116 | end; 117 | 118 | procedure TestTRlxRazorEngine.TestGetTemplatesFolder; 119 | var 120 | ReturnValue: string; 121 | begin 122 | // ReturnValue := FRlxRazorEngine.GetTemplatesFolder; 123 | // TODO: Validate method results 124 | end; 125 | 126 | procedure TestTRlxRazorEngine.TestGetOtherValue; 127 | var 128 | ReturnValue: string; 129 | FieldName: string; 130 | ObjectName: string; 131 | begin 132 | // TODO: Setup method call parameters 133 | // ReturnValue := FRlxRazorEngine.GetOtherValue(ObjectName, FieldName); 134 | // TODO: Validate method results 135 | end; 136 | 137 | procedure TestTRlxRazorEngine.TestGetLang; 138 | var 139 | ReturnValue: string; 140 | FieldName: string; 141 | begin 142 | // TODO: Setup method call parameters 143 | // ReturnValue := FRlxRazorEngine.GetLang(FieldName); 144 | // TODO: Validate method results 145 | end; 146 | 147 | procedure TestTRlxRazorEngine.TestGetScaffolding; 148 | var 149 | ReturnValue: string; 150 | strDottedClass: string; 151 | begin 152 | // TODO: Setup method call parameters 153 | // ReturnValue := FRlxRazorEngine.GetScaffolding(strDottedClass); 154 | // TODO: Validate method results 155 | end; 156 | 157 | procedure TestTRlxRazorEngine.TestAddWarning; 158 | var 159 | strWarning: string; 160 | begin 161 | // TODO: Setup method call parameters 162 | FRlxRazorEngine.AddWarning(strWarning); 163 | // TODO: Validate method results 164 | end; 165 | 166 | procedure TestTRlxRazorEngine.TestProcessRequest; 167 | var 168 | ReturnValue: string; 169 | userRoles: string; 170 | inFolder: string; 171 | LanguageID: Integer; 172 | LoggedUser: Boolean; 173 | Found: Boolean; 174 | Request: TWebRequest; 175 | begin 176 | // TODO: Setup method call parameters 177 | //ReturnValue := FRlxRazorEngine.ProcessRequest(Request, Found, LoggedUser, LanguageID, 178 | // inFolder, userRoles); 179 | // TODO: Validate method results 180 | end; 181 | 182 | procedure TestTRlxRazorEngine.TestGetLangFormats; 183 | var 184 | ReturnValue: TFormatSettings; 185 | language_id: Integer; 186 | begin 187 | // TODO: Setup method call parameters 188 | // ReturnValue := FRlxRazorEngine.GetLangFormats(language_id); 189 | // TODO: Validate method results 190 | end; 191 | 192 | procedure TestTRlxRazorProcessor.RunLoginPermissionScript; 193 | var 194 | strBlock: string; 195 | begin 196 | strBlock := 'Something @LoginRequired.MyGroup else'; 197 | strBlock := FRlxRazorProcessor.DoBlock(strBlock); 198 | end; 199 | 200 | procedure TestTRlxRazorProcessor.RunLoginRequiredScript; 201 | var 202 | strBlock: string; 203 | begin 204 | strBlock := 'Something @LoginRequired else'; 205 | strBlock := FRlxRazorProcessor.DoBlock(strBlock); 206 | end; 207 | 208 | procedure TestTRlxRazorProcessor.SetUp; 209 | begin 210 | FRlxRazorProcessor := TRlxRazorProcessor.Create (nil); 211 | end; 212 | 213 | procedure TestTRlxRazorProcessor.TearDown; 214 | begin 215 | FRlxRazorProcessor.Free; 216 | FRlxRazorProcessor := nil; 217 | end; 218 | 219 | procedure TestTRlxRazorProcessor.TestAddToDictionary; 220 | var 221 | simpleObj: TSimpleObj; 222 | begin 223 | // add non-owned object to processor 224 | simpleObj := TSimpleObj.Create; 225 | try 226 | FRlxRazorProcessor.AddToDictionary(SampleObjectName, SimpleObj, False); 227 | CheckEquals (FRlxRazorProcessor.DataObjects.Count, 1); 228 | CheckEquals (FRlxRazorProcessor.InDictionary (SampleObjectName), True); 229 | FRlxRazorProcessor.DataObjects.Remove(SampleObjectName); 230 | CheckEquals (FRlxRazorProcessor.DataObjects.Count, 0); 231 | finally 232 | simpleObj.Free; 233 | end; 234 | end; 235 | 236 | procedure TestTRlxRazorProcessor.TestDoBlock; 237 | var 238 | ReturnValue: string; 239 | strBlock: string; 240 | begin 241 | // generic text should remain the same after processing 242 | strBlock := 'Anything'; 243 | ReturnValue := FRlxRazorProcessor.DoBlock(strBlock); 244 | CheckEquals (strBlock, ReturnValue); 245 | end; 246 | 247 | procedure TestTRlxRazorProcessor.TestDoubleAt; 248 | var 249 | ReturnValue: string; 250 | strBlock: string; 251 | begin 252 | // double @@ shoudl be returned as single @ 253 | strBlock := 'Anything @something'; 254 | ReturnValue := FRlxRazorProcessor.DoBlock(DoubleAtSymbol (strBlock)); 255 | CheckEquals (strBlock, ReturnValue); 256 | end; 257 | 258 | procedure TestTRlxRazorProcessor.TestForIfList; 259 | var 260 | list: TList; 261 | simpleObj: TSimpleObj; 262 | strBlock: string; 263 | ReturnValue: string; 264 | 265 | begin 266 | // create a list with 2 objects 267 | list := TList.Create; //owns objects 268 | simpleObj := TSimpleObj.Create; 269 | simpleObj.AField := 'one'; 270 | list.Add(simpleObj); 271 | simpleObj := TSimpleObj.Create; 272 | simpleObj.AField := 'two'; 273 | list.Add(simpleObj); 274 | try 275 | FRlxRazorProcessor.AddToDictionary('list', list, False); 276 | 277 | strBlock := '@foreach (var item in list) {@item.AField,}'; 278 | ReturnValue := Trim(FRlxRazorProcessor.DoBlock(strBlock)); 279 | CheckEquals ('one, two,', ReturnValue); 280 | 281 | FRlxRazorProcessor.DataObjects.Remove('list'); 282 | finally 283 | list.Free; 284 | end; 285 | 286 | end; 287 | 288 | procedure TestTRlxRazorProcessor.TestIfEmptyString; 289 | var 290 | ReturnValue: string; 291 | strBlock: string; 292 | simpleObj: TSimpleObj; 293 | begin 294 | simpleObj := TSimpleObj.Create; 295 | try 296 | FRlxRazorProcessor.AddToDictionary(SampleObjectName, SimpleObj, False); 297 | strBlock := '@if ' + SampleObjectName + '.' + SampleFieldName + ' {Hello}'; 298 | ReturnValue := Trim(FRlxRazorProcessor.DoBlock(strBlock)); 299 | CheckEquals ('', ReturnValue); 300 | FRlxRazorProcessor.DataObjects.Remove(SampleObjectName); 301 | finally 302 | simpleObj.Free; 303 | end; 304 | end; 305 | 306 | procedure TestTRlxRazorProcessor.TestIfFalse; 307 | var 308 | ReturnValue: string; 309 | strBlock: string; 310 | simpleObj: TSimpleObj; 311 | begin 312 | simpleObj := TSimpleObj.Create; 313 | try 314 | simpleObj.ABool := False; 315 | FRlxRazorProcessor.AddToDictionary(SampleObjectName, SimpleObj, False); 316 | strBlock := '@if ' + SampleObjectName + '.' + SampleBoolFieldName + ' {Hello}'; 317 | ReturnValue := Trim(FRlxRazorProcessor.DoBlock(strBlock)); 318 | CheckEquals ('', ReturnValue); 319 | FRlxRazorProcessor.DataObjects.Remove(SampleObjectName); 320 | finally 321 | simpleObj.Free; 322 | end; 323 | end; 324 | 325 | procedure TestTRlxRazorProcessor.TestIfNotEmptyString; 326 | var 327 | ReturnValue: string; 328 | strBlock: string; 329 | simpleObj: TSimpleObj; 330 | begin 331 | simpleObj := TSimpleObj.Create; 332 | try 333 | simpleObj.AField := 'something'; 334 | FRlxRazorProcessor.AddToDictionary(SampleObjectName, SimpleObj, False); 335 | strBlock := '@if ' + SampleObjectName + '.' + SampleFieldName + ' {Hello}'; 336 | ReturnValue := Trim(FRlxRazorProcessor.DoBlock(strBlock)); 337 | CheckEquals ('Hello', ReturnValue); 338 | FRlxRazorProcessor.DataObjects.Remove(SampleObjectName); 339 | finally 340 | simpleObj.Free; 341 | end; 342 | end; 343 | 344 | procedure TestTRlxRazorProcessor.TestIfTrue; 345 | var 346 | ReturnValue: string; 347 | strBlock: string; 348 | simpleObj: TSimpleObj; 349 | begin 350 | simpleObj := TSimpleObj.Create; 351 | try 352 | simpleObj.ABool := True; 353 | FRlxRazorProcessor.AddToDictionary(SampleObjectName, SimpleObj, False); 354 | strBlock := '@if ' + SampleObjectName + '.' + SampleBoolFieldName + ' {Hello}'; 355 | ReturnValue := Trim(FRlxRazorProcessor.DoBlock(strBlock)); 356 | CheckEquals ('Hello', ReturnValue); 357 | FRlxRazorProcessor.DataObjects.Remove(SampleObjectName); 358 | finally 359 | simpleObj.Free; 360 | end; 361 | end; 362 | 363 | procedure TestTRlxRazorProcessor.TestIsLogged; 364 | var 365 | strBlock: string; 366 | ReturnValue: string; 367 | begin 368 | FRlxRazorProcessor.UserLoggedIn := True; 369 | strBlock := 'Something @LoginRequired else'; 370 | ReturnValue := FRlxRazorProcessor.DoBlock(strBlock); 371 | CheckEquals('Something else', ReturnValue); 372 | end; 373 | 374 | procedure TestTRlxRazorProcessor.TestIsNotLogged; 375 | begin 376 | FRlxRazorProcessor.UserLoggedIn := False; 377 | CheckException(RunLoginRequiredScript, ERlxLoginRequired); 378 | end; 379 | 380 | procedure TestTRlxRazorProcessor.TestPermission; 381 | var 382 | strBlock: string; 383 | ReturnValue: string; 384 | begin 385 | FRlxRazorProcessor.UserLoggedIn := True; 386 | FRlxRazorProcessor.UserRoles := 'Full, MyGroup, More'; 387 | strBlock := 'Something @LoginRequired.MyGroup else'; 388 | ReturnValue := FRlxRazorProcessor.DoBlock(strBlock); 389 | CheckEquals('Something else', ReturnValue); 390 | end; 391 | 392 | procedure TestTRlxRazorProcessor.TestUnicode; 393 | var 394 | ReturnValue: string; 395 | strBlock: UTF8String; 396 | begin 397 | // generic text should remain the same after processing 398 | strBlock := 'âäçíïòýąÈËϘϟϡڏڧۋﻙﻵ'; 399 | ReturnValue := FRlxRazorProcessor.DoBlock(strBlock, TEncoding.UTF8); 400 | CheckEquals (string(strBlock), ReturnValue); 401 | end; 402 | 403 | procedure TestTRlxRazorProcessor.TestValueEvent; 404 | var 405 | ReturnValue: string; 406 | strBlock: string; 407 | begin 408 | FRlxRazorProcessor.OnValue := TestValueHandler; 409 | strBlock := 'Anything @' + SampleObjectName + '.' + SampleFieldName; 410 | ReturnValue := FRlxRazorProcessor.DoBlock(strBlock); 411 | CheckEquals ('Anything ' + SampleFieldValue, ReturnValue); 412 | end; 413 | 414 | procedure TestTRlxRazorProcessor.TestValueFromDictionary; 415 | var 416 | simpleObj: TSimpleObj; 417 | strBlock: string; 418 | ReturnValue: string; 419 | begin 420 | // add non-owned object to processor 421 | simpleObj := TSimpleObj.Create; 422 | try 423 | simpleObj.AField := SampleFieldValue; 424 | FRlxRazorProcessor.AddToDictionary(SampleObjectName, SimpleObj, False); 425 | strBlock := 'Anything @' + SampleObjectName + '.' + SampleFieldName; 426 | ReturnValue := FRlxRazorProcessor.DoBlock(strBlock); 427 | CheckEquals ('Anything ' + SampleFieldValue, ReturnValue); 428 | FRlxRazorProcessor.DataObjects.Remove(SampleObjectName); 429 | finally 430 | simpleObj.Free; 431 | end; 432 | end; 433 | 434 | procedure TestTRlxRazorProcessor.TestValueHandler(Sender: TObject; 435 | const ObjectName, FieldName: string; var ReplaceText: string); 436 | begin 437 | if SameText (ObjectName, SampleObjectName) and 438 | SameText (FieldName, SampleFieldName) then 439 | ReplaceText := SampleFieldValue; 440 | end; 441 | 442 | procedure TestTRlxRazorProcessor.TestWrongPermission; 443 | begin 444 | FRlxRazorProcessor.UserLoggedIn := False; 445 | FRlxRazorProcessor.UserRoles := ''; 446 | CheckException(RunLoginPermissionScript, ERlxLoginRequired); 447 | end; 448 | 449 | { TSimpleObj } 450 | 451 | procedure TSimpleObj.SetABool(const Value: Boolean); 452 | begin 453 | FABool := Value; 454 | end; 455 | 456 | procedure TSimpleObj.SetAField(const Value: string); 457 | begin 458 | FAField := Value; 459 | end; 460 | 461 | initialization 462 | // Register any test cases with the test runner 463 | RegisterTest(TestTRlxRazorEngine.Suite); 464 | RegisterTest(TestTRlxRazorProcessor.Suite); 465 | end. 466 | 467 | -------------------------------------------------------------------------------- /test/UTestRlxRazorEngine.pas: -------------------------------------------------------------------------------- 1 | unit UTestRlxRazorEngine; 2 | 3 | interface 4 | 5 | uses 6 | TestFramework, 7 | RlxRazor; 8 | 9 | type 10 | TTestRlxRazorEngine = class(TTestCase) 11 | private 12 | FRlxRazorEngine: TRlxRazorEngine; 13 | FWarning: string; 14 | procedure DoValue(Sender: TObject; 15 | const ObjectName, FieldName: string; 16 | var ReplaceText: string); 17 | procedure DoLang(Sender: TObject; 18 | const FieldName: string; 19 | var ReplaceText: string); 20 | procedure DoScaffolding(Sender: TObject; 21 | const qualifClassName: string; 22 | var ReplaceText: string); 23 | procedure DoWarn(Sender: TObject; 24 | const strWarning: string); 25 | protected 26 | procedure SetUp; override; 27 | procedure TearDown; override; 28 | published 29 | procedure TestCreate; 30 | procedure TestGetTemplatesFolder; 31 | procedure TestGetOtherValue; 32 | procedure TestGetLang; 33 | procedure TestGetScaffolding; 34 | procedure TestAddWarning; 35 | procedure TestGetLangFormats; 36 | procedure TestLocaleDictionary; 37 | procedure TestAddToDictionary; 38 | procedure TestInDictionary; 39 | procedure TestDataObjects; 40 | end; 41 | 42 | implementation 43 | 44 | uses 45 | SysUtils, 46 | RlxLocales; 47 | 48 | const 49 | cObjectName = 'TEmployee'; 50 | cFieldName = 'First_Name'; 51 | cFieldNameGerman = 'Vorname'; 52 | cReplaceText = 'Roberto'; 53 | cUnknown = 'Unkown'; 54 | cWarning = 'Hire Date is missing'; 55 | 56 | type 57 | TEmployee = class 58 | private 59 | FJOB_CODE: string; 60 | FJOB_GRADE: SmallInt; 61 | FEMP_NO: SmallInt; 62 | FDEPT_NO: string; 63 | FFIRST_NAME: string; 64 | FJOB_COUNTRY: string; 65 | FLAST_NAME: string; 66 | FSALARY: string; 67 | FHIRE_DATE: TDateTime; 68 | FPHONE_EXT: string; 69 | public 70 | property EMP_NO: SmallInt read FEMP_NO write FEMP_NO; 71 | property FIRST_NAME: string read FFIRST_NAME write FFIRST_NAME; 72 | property LAST_NAME: string read FLAST_NAME write FLAST_NAME; 73 | property PHONE_EXT: string read FPHONE_EXT write FPHONE_EXT; 74 | property HIRE_DATE: TDateTime read FHIRE_DATE write FHIRE_DATE; 75 | property DEPT_NO: string read FDEPT_NO write FDEPT_NO; 76 | property JOB_CODE: string read FJOB_CODE write FJOB_CODE; 77 | property JOB_GRADE: SmallInt read FJOB_GRADE write FJOB_GRADE; 78 | property JOB_COUNTRY: string read FJOB_COUNTRY write FJOB_COUNTRY; 79 | property SALARY: string read FSALARY write FSALARY; 80 | end; 81 | 82 | 83 | { TTestRlxRazorEngine } 84 | 85 | procedure TTestRlxRazorEngine.DoLang(Sender: TObject; 86 | const FieldName: string; 87 | var ReplaceText: string); 88 | begin 89 | if FieldName = cFieldName then 90 | ReplaceText := cFieldNameGerman 91 | else 92 | ReplaceText := cUnknown; 93 | end; 94 | 95 | procedure TTestRlxRazorEngine.DoScaffolding(Sender: TObject; 96 | const qualifClassName: string; 97 | var ReplaceText: string); 98 | begin 99 | if qualifClassName = Format('%s.%s', [cObjectName, cFieldName]) then 100 | ReplaceText := cReplaceText 101 | else 102 | ReplaceText := cUnknown; 103 | end; 104 | 105 | procedure TTestRlxRazorEngine.DoValue(Sender: TObject; 106 | const ObjectName, FieldName: string; 107 | var ReplaceText: string); 108 | begin 109 | if (ObjectName = cObjectName) and (FieldName = cFieldName) then 110 | ReplaceText := cReplaceText 111 | else 112 | ReplaceText := cUnknown; 113 | end; 114 | 115 | procedure TTestRlxRazorEngine.DoWarn(Sender: TObject; 116 | const strWarning: string); 117 | begin 118 | FWarning := strWarning; 119 | end; 120 | 121 | procedure TTestRlxRazorEngine.SetUp; 122 | begin 123 | inherited; 124 | FRlxRazorEngine := TRlxRazorEngine.Create(nil); 125 | end; 126 | 127 | procedure TTestRlxRazorEngine.TearDown; 128 | begin 129 | FRlxRazorEngine.Free; 130 | inherited; 131 | end; 132 | 133 | procedure TTestRlxRazorEngine.TestAddToDictionary; 134 | var 135 | Employee: TEmployee; 136 | DictItem: TRazDictItem; 137 | begin 138 | Employee := TEmployee.Create; 139 | try 140 | CheckEquals(0, FRlxRazorEngine.DataObjects.Count, 'DataObjects.Count'); 141 | FRlxRazorEngine.AddToDictionary('employee', Employee, False); 142 | CheckEquals(1, FRlxRazorEngine.DataObjects.Count, 'DataObjects.Count'); 143 | CheckTrue(FRlxRazorEngine.DataObjects.ContainsKey('employee'), 'DataObjects.ContainsKey(''employee'')'); 144 | FRlxRazorEngine.DataObjects.TryGetValue('employee', DictItem); 145 | CheckIs(DictItem.TheObject, TEmployee, 'DictItem.TheObject'); 146 | finally 147 | Employee.Free; 148 | end; 149 | end; 150 | 151 | procedure TTestRlxRazorEngine.TestAddWarning; 152 | begin 153 | FWarning := EmptyStr; 154 | FRlxRazorEngine.OnWarn := DoWarn; 155 | FRlxRazorEngine.AddWarning(cWarning); 156 | CheckEquals(cWarning, FWarning, 'Warning'); 157 | end; 158 | 159 | procedure TTestRlxRazorEngine.TestCreate; 160 | begin 161 | CheckEquals(0, RlxLocaleDictionary.Count, 'LocaleDictionary.Count'); 162 | CheckEquals(0, FRlxRazorEngine.DataObjects.Count, 'DataObjects.Count'); 163 | CheckEquals(Ord(ddIgnore), Ord(FRlxRazorEngine.DictionaryDuplicates), 'DictionaryDuplicates'); 164 | end; 165 | 166 | procedure TTestRlxRazorEngine.TestDataObjects; 167 | begin 168 | TestAddToDictionary; 169 | end; 170 | 171 | procedure TTestRlxRazorEngine.TestGetLang; 172 | var 173 | sReplaceText: string; 174 | begin 175 | FRlxRazorEngine.OnLang := DoLang; 176 | sReplaceText := FRlxRazorEngine.GetLang(cFieldName); 177 | CheckEquals(cFieldNameGerman, sReplaceText, 'ReplaceText'); 178 | sReplaceText := FRlxRazorEngine.GetLang(cUnknown); 179 | CheckEquals(cUnknown, sReplaceText, 'ReplaceText'); 180 | end; 181 | 182 | procedure TTestRlxRazorEngine.TestGetLangFormats; 183 | const 184 | cGermanLanguageID = 1; 185 | var 186 | FormatResult, GermanFormatSettings: TFormatSettings; 187 | begin 188 | FormatResult := FRlxRazorEngine.GetLangFormats(cGermanLanguageID); 189 | CheckEquals(FormatSettings.DateSeparator, FormatResult.DateSeparator, 'DateSeparator'); 190 | CheckEquals(FormatSettings.ShortDateFormat, FormatResult.ShortDateFormat, 'ShortDateFormat'); 191 | GermanFormatSettings.DateSeparator := '.'; 192 | GermanFormatSettings.ShortDateFormat := 'dd.mm.yyyy'; 193 | RlxLocaleDictionary.Add(cGermanLanguageID, GermanFormatSettings); 194 | FormatResult := FRlxRazorEngine.GetLangFormats(cGermanLanguageID); 195 | CheckEquals(GermanFormatSettings.DateSeparator, FormatResult.DateSeparator, 'DateSeparator'); 196 | CheckEquals(GermanFormatSettings.ShortDateFormat, FormatResult.ShortDateFormat, 'ShortDateFormat'); 197 | end; 198 | 199 | procedure TTestRlxRazorEngine.TestGetOtherValue; 200 | var 201 | sReplaceText: string; 202 | begin 203 | FRlxRazorEngine.OnValue := DoValue; 204 | sReplaceText := FRlxRazorEngine.GetOtherValue(cObjectName, cFieldName); 205 | CheckEquals(cReplaceText, sReplaceText, 'ReplaceText'); 206 | sReplaceText := FRlxRazorEngine.GetOtherValue(cObjectName, cUnknown); 207 | CheckEquals(cUnknown, sReplaceText, 'ReplaceText'); 208 | end; 209 | 210 | procedure TTestRlxRazorEngine.TestGetScaffolding; 211 | var 212 | sReplaceText: string; 213 | begin 214 | FRlxRazorEngine.OnScaffolding := DoScaffolding; 215 | sReplaceText := FRlxRazorEngine.GetScaffolding(Format('%s.%s', [cObjectName, cFieldName])); 216 | CheckEquals(cReplaceText, sReplaceText, 'ReplaceText'); 217 | sReplaceText := FRlxRazorEngine.GetScaffolding(Format('%s.%s', [cObjectName, cUnknown])); 218 | CheckEquals(cUnknown, sReplaceText, 'ReplaceText'); 219 | end; 220 | 221 | procedure TTestRlxRazorEngine.TestGetTemplatesFolder; 222 | const 223 | cFilesFolder = 'c:\FilesFolder\'; 224 | cTemplatesFolder = 'c:\TemplatesFolder\'; 225 | begin 226 | FRlxRazorEngine.FilesFolder := cFilesFolder; 227 | CheckEquals(cFilesFolder, FRlxRazorEngine.GetTemplatesFolder, 'GetTemplatesFolder'); 228 | FRlxRazorEngine.TemplatesFolder := cTemplatesFolder; 229 | CheckEquals(cTemplatesFolder, FRlxRazorEngine.GetTemplatesFolder, 'GetTemplatesFolder'); 230 | end; 231 | 232 | procedure TTestRlxRazorEngine.TestInDictionary; 233 | var 234 | Employee: TEmployee; 235 | DictItem: TRazDictItem; 236 | begin 237 | Employee := TEmployee.Create; 238 | try 239 | CheckEquals(0, FRlxRazorEngine.DataObjects.Count, 'DataObjects.Count'); 240 | FRlxRazorEngine.AddToDictionary('employee', Employee, False); 241 | CheckEquals(1, FRlxRazorEngine.DataObjects.Count, 'DataObjects.Count'); 242 | CheckTrue(FRlxRazorEngine.InDictionary('employee'), 'InDictionary(''employee'')'); 243 | finally 244 | Employee.Free; 245 | end; 246 | end; 247 | 248 | procedure TTestRlxRazorEngine.TestLocaleDictionary; 249 | const 250 | cGermanLanguageID = 2; 251 | var 252 | FormatResult, GermanFormatSettings: TFormatSettings; 253 | begin 254 | // it is now a global structure, so there are already some values in it 255 | // CheckEquals(0, RlxLocaleDictionary.Count, 'LocaleDictionary.Count'); 256 | GermanFormatSettings.DateSeparator := '.'; 257 | GermanFormatSettings.ShortDateFormat := 'dd.mm.yyyy'; 258 | RlxLocaleDictionary.Add(cGermanLanguageID, GermanFormatSettings); 259 | CheckTrue(RlxLocaleDictionary.ContainsKey(cGermanLanguageID), 'LocaleDictionary.ContainsKey(cGermanLanguageID)'); 260 | RlxLocaleDictionary.TryGetValue(cGermanLanguageID, FormatResult); 261 | CheckEquals(GermanFormatSettings.DateSeparator, FormatResult.DateSeparator, 'DateSeparator'); 262 | CheckEquals(GermanFormatSettings.ShortDateFormat, FormatResult.ShortDateFormat, 'ShortDateFormat'); 263 | end; 264 | 265 | initialization 266 | // Register any test cases with the test runner 267 | RegisterTest(TTestRlxRazorEngine.Suite); 268 | 269 | end. 270 | -------------------------------------------------------------------------------- /test/Win32/Debug/dunit.ini: -------------------------------------------------------------------------------- 1 | [GUITestRunner Config] 2 | AutoSave=1 3 | Left=52 4 | Top=52 5 | Width=774 6 | Height=638 7 | Maximized=0 8 | UseRegistry=0 9 | ResultsPanel.Height=174 10 | ErrorMessage.Height=75 11 | ErrorMessage.Visible=1 12 | FailureList.ColumnWidth[0]=120 13 | FailureList.ColumnWidth[1]=100 14 | FailureList.ColumnWidth[2]=200 15 | FailureList.ColumnWidth[3]=326 16 | HideTestNodesOnOpen=0 17 | BreakOnFailures=0 18 | FailOnNoChecksExecuted=0 19 | FailOnMemoryLeaked=0 20 | IgnoreSetUpTearDownLeaks=0 21 | ReportMemoryLeakTypes=0 22 | SelectTestedNode=1 23 | WarnOnFailTestOverride=0 24 | PopupX=350 25 | PopupY=30 26 | 27 | --------------------------------------------------------------------------------