DEV Community

Sempare Limited
Sempare Limited

Posted on

1

Using the ternary expression in the Sempare Template Engine for Delphi

The Sempare Template Engine (available at https://github.com/sempare/sempare-delphi-template-engine and GetIt) is a versatile templating system designed specifically for Delphi developers to streamline the creation and management of dynamic HTML, text, or any other text-based output formats. Whether you are building web applications, reports, or email templates, the Sempare Template Engine offers a powerful yet straightforward solution that integrates with minimal boilerplate into Delphi projects. The template engine has been around since 2019 and has many features for you to explore.

Sometimes, you may want an inline ternary expression to simplify more verbose if-expressions.

e.g. You may have something like:

<% x := 123 %>
<% if x > 100 %>
   a big value
<% else %>
   a low value
<% end %>
Enter fullscreen mode Exit fullscreen mode

We could convert the above into:

<% x := 123 %>
<% print('a big value' if x > 100 else 'a low value') %>
Enter fullscreen mode Exit fullscreen mode

Conclusion

The above tutorial illustrated how a ternary expression could

The Sempare Template Engine is very flexible, configurable and extensible, allowing for a good seperation of concerns between your business logic that will access data, and the templating engine that will render/present your data as required.

The template engine is available on https://github.com/sempare/sempare-delphi-template-engine and via Embarcadero GetIt.

Sponsorship Required

Please help us maintain the project by supporting Sempare via GitHub sponsors (https://github.com/sponsors/sempare) or via our payment link (https://buy.stripe.com/aEU7t61N88pffQIdQQ). Sponsors can obtain access to our integrated IDE wizard for RAD Studio.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more