Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. procedure SayHelloWorld(ctx: PTmplContext; var output: PChar;
  2. arg_count : longint; var args : PChar); cdecl;
  3. const
  4. msg = 'Hello World';
  5. begin
  6. output := template_malloc (Length (msg) + 1);
  7. template_strcpy(output, msg);
  8. end;
  9.  
  10. procedure TlibtmplTest.testRegisterSimple;
  11. var
  12. tmpl : PTmplContext;
  13. output : Pchar;
  14. begin
  15. tmpl := template_init;
  16. template_register_simple(tmpl, 'say_hello', @SayHelloWorld);
  17. template_parse_string(tmpl, '<!--#say_hello-->', output);
  18. AssertEquals('Register simple', 'Hello World', output);
  19. template_free_output(output);
  20. template_destroy(tmpl);
  21. end;
Add Comment
Please, Sign In to add comment