Sempare Template Engine
Template engines are used often in in the technology where text needs to be customised by substituting variables with values from a data source. Examples where this may take place:
или Зарегистрируйся (Object Pascal) that allows for templates to be created easily and efficiently by providing a simple and easy to use interface.
Home: Для просмотра ссылки Войди или Зарегистрируйся
Copyright © Для просмотра ссылки Войдиили Зарегистрируйся
Template engines are used often in in the technology where text needs to be customised by substituting variables with values from a data source. Examples where this may take place:
- web sites using template engines (or languages)
- code generation
- mail merge
- notification messages
- statements
- if, elif, else statements
- for and while statements
- include statement
- with statement
- function/method calls
- expressions
- simple expression evaluation (logical, numerical and string)
- variable definition
- functions and methods calls
- dereference records, classes, arrays, JSON objects, TDataSet descendants and dynamic arrays
- ternary operator
- safety
- max run-time protection
- customisation
- custom script token replacement
- add custom functions
- strip recurring spaces and new lines
- lazy template resolution
- parse time evaluation of expressions/statements
- allow use of custom encoding (UTF-8 with BOM, UTF-8 without BOM, ASCII, etc)
- extensibile RTTI interface to easily dereference classes and interfaces (current customisations for IVelocityVariables, TDictionary, TJsonObject)
Код:
program Example;
uses
Sempare.Template;
type
TInformation = record
name: string;
favourite_sport : string;
end;
begin
var tpl := Template.parse('My name is <% name %>. My favourite sport is <% favourite_sport %>.');
var information : TInformation;
information.name := 'conrad';
information.favourite_sport := 'ultimate';
writeln(Template.eval(tpl, information));
end.
Copyright © Для просмотра ссылки Войди
Последнее редактирование: