Aus öffentlichen Paketdaten erstellte Orientierung.
Jinja ist eine Dart-Implementierung des Jinja2-Vorlagen-Engines, die dynamische Inhaltsgenerierung mit Variablen, Ausdrücken, Kontrollstrukturen und Template-Erbschaft ermöglicht. Es unterstützt Server-Seite-Rendern und integriert sich gut mit Web-Frameworks. Für den Einsatz in Backend-Diensten und Web-Anwendungen konzipiert, ermöglicht es Entwicklern durch leistungsstarke Vorlagenfunktionen die Trennung von Logik und Darstellung. Das Paket läuft auf allen wichtigen Plattformen, einschließlich Mobilgeräte, Web und Desktop.
Anwendungsfälle
Serverseitige Rendern
Dynamische HTML-Generierung
Vorlagenbasierte Inhaltserstellung
Webanwendungslayouts
API-getriebene Vorlagen
Multiplattform-Vorlagen
Hauptmerkmale
Variablen- und Ausdruckssupport
Steuerstrukturen (if, for)
Vorlagenvererbung
Plattformübergreifende Kompatibilität
Leicht und schnell
Einfache Integration mit Dart-Anwendungen
Geeignet für
Backend-Entwickler
Full-Stack-Webentwickler
Vorlagenbasierte Anwendungen
Serverseitig gerenderte Web-Anwendungen
Dart-basierte Web-Frameworks
Hinweise
Nicht für die Client-Seiten-Rendernung vorgesehen
Eingeschränkte Dokumentation
Kenntnis der Jinja2-Syntax erforderlich
Am besten geeignet für Serverumgebungen
Keine integrierten Sicherheitsfilter
Kann zusätzliche Überprüfung für Benutzereingaben erfordern
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
jinja
Jinja (3.x) server-side template engine port for Dart 3.
Variables, expressions, control structures and template inheritance.
Documentation
It is mostly similar to Jinja templates documentation, differences provided below.
work in progress.
Differences with Python version
Auto-escaping and related statements, filters and tests have been removed due to the impossibility of extending String.
Use the escape filter manually or escape values before passing them to the template.
The default filter compares values with null.
The defined and undefined tests compare values with null.
The map filter also compares values with null.
Use attribute and item filters for object.attribute and object[item] expressions.
If Environment({getAttribute}) is not passed, the getItem method will be used.
This allows you to use {{ map.key }} as an expression equivalent to {{ map['key'] }}.
String slices and negative indexes are not supported (list slicing [start:stop] with non-negative integers is supported).
Macro arguments without default values are required.
No FilterArgumentError error class.
No *args and **kwargs arguments.
No Template module.
work in progress
Dynamically invoked members (can increase the size of the JS output)
[], +, -, *, /, ~/, % operators
object.length getter
object.call getter
Function.apply(function, ...)
Example
import'package:jinja/jinja.dart';
// ...var environment = Environment(blockStart: '...', blockEnd: '...');
var template = environment.fromString('...source...');
print(template.render({'key': value}));
// or write directly to StringSink (IOSink, HttpResponse, ...)
template.renderTo(stringSink, {'key': value});
Contributions are welcome! Please open an issue or pull request on GitHub.
Look at the ToDo list and comments in the code for ideas on what to work on.
There are no strict rules, but please try to follow the existing code style.
As non-native English speaker and learner, I will be grateful for any
corrections in the documentation and code comments.
Support
Post issues and feature requests on the GitHub issue tracker.