Что нового?

Welcome to DUMPz.ws - старейший компьютерный форум (c) 2004-2021

Присоединяйтесь к нашему сообществу сейчас, чтобы получить доступ ко всем функциям форума. После регистрации Вы сможете создавать темы, публиковать ответы, общаться в чате с единомышленниками.
Blue
Red
Green
Orange
Voilet
Slate
Dark

Component Sempare Template Engine

FireWind

Moderator
Регистрация
2 Дек 2005
Сообщения
1,692
Реакции
1,026
Credits
715
Native language | Родной язык
Русский
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:
  • web sites using template engines (or languages)
  • code generation
  • mail merge
  • notification messages
The Sempare Template Engine is small templating engine for Как увидеть ссылки? | How to see hidden links? (Object Pascal) that allows for templates to be created easily and efficiently by providing a simple and easy to use interface.
  • 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.
Home: Как увидеть ссылки? | How to see hidden links?
Copyright © Как увидеть ссылки? | How to see hidden links?
 
Последнее редактирование:

FireWind

Moderator
Регистрация
2 Дек 2005
Сообщения
1,692
Реакции
1,026
Credits
715
Native language | Родной язык
Русский
Sempare Template Engine v1.3.0
  • Documented ignorenl block statement and added tests
  • Added double quote support on strings
  • Added escape support in strings
 

FireWind

Moderator
Регистрация
2 Дек 2005
Сообщения
1,692
Реакции
1,026
Credits
715
Native language | Родной язык
Русский
Sempare Template Engine v1.4.0
  • NEW: Add NL, CR, TAB, CRNL variables
  • NEW: Add Chr() and Ord(), PadLeft(), PadRight(), Spaces(), Tabs(), NL(), CRNL() helper functions
  • NEW: Provide Context.StartStripToken and Context.EndStripToken to allow for content to be ignored between template statements
  • UPDATE: Documentation updates
  • CHANGE: Context.Options updated to require eoAllowIgnoreNL if ignorenl statement is to be processed
  • FIX: TNewLineStreamWriter fixed to handle carriage return correctly
  • FIX: Fix double free bug on ParseFile