Releases: Urquelle/templ
0.4-alpha
status
project is still in alpha stage. however, many filters and most tests were implemented.
enhancements
- linux support
- json support
- introspection support
- custom procedures support for
- custom global procedures
- custom type procedures
- custom filter procedures
- custom tester procedures
bugs fixed
- comments got printed to result string
- escape backslash got printed to result string
- resolution and execution of parentheses expression
v0.3.1
user api
fixes broken user api and makes it more clear how to use.
statements
- better if-parsing and code reduction overall in resovle and execution stage.
- with statement was fixed, so it doesn't leak symbols to the outer scope.
bool and none
previously the none
expression was part of bool
. now it's a separate entity.
v0.3 templ release
v0.3 release
a major refactoring took place in this release, so that the code became easier to read and understand.
all in all, this release turned out to be bigger than planned. see below for the full description of changes that went in to this release.
global methods
this release implements the list of global methods in full capacity.
implements global method range
- 4e035d4eimplements global method lipsum
- e1c1639implements global method dict
- 8790895implements global method cycler
- 09367b0implements global method joiner
- 606cbcdimplements global method namespace
- 212576d
filter
the following filter were implemented in this release
implements filter truncate
- bb04d7bimplements filter attr
- 6bdfdb2implements filter center
- 9df097d8
tests
the following tests were implemented in this release
expressions and statements
this release offers more support for expressions and statements that the original jinja template engine supports.
implements with statement
- 172300bimplements expressions left of assignment
- f203ab9implements break & continue in for loops
- 843c77cimplements support for dict
- 838422aimplements none expression
- 7bcd758- implements better support for whitespace control
implements if expression on all expressions
- 843939implements tilde operator
- 44e83ca
error messages
this release implements the collection of all raised errors and warnings in distinct collections, which can be iterated over by the user later on.
if ( status_is_error() ) {
for ( int i = 0; i < status_num_errors(); ++i ) {
Status *error = status_error_get(i);
fprintf(stderr, "%s in %s line %lld\n", status_message(error),
status_filename(error), status_line(error));
}
for ( int i = 0; i < status_num_warnings(); ++i ) {
Status *warning = status_warning_get(i);
fprintf(stderr, "%s in %s line %lld\n", status_message(warning),
status_filename(warning), status_line(warning));
}
}
v0.2 der jinja2 engine in c++
themen dieses releases
api kapselung
die gesamte implementierung ist nun in eigenem namespace templ
und verunreinigt somit nicht den globalen sichtbarkeitsbereich. der benutzer kann durch die angabe von using namespace templ::api
vordefinierte symbole in seinen gültigkeitsbereich ziehen und die templ api frei nutzen.
#include "templ.cpp"
int main() {
using namespace templ::api;
templ_init(MB(100), MB(100), MB(100));
Templ_Vars vars = templ_vars();
Templ_Var *name = templ_var("name", var_str("heinrich"));
templ_vars_add(&vars, name);
Parsed_Templ *templ = templ_compile_string("servus {{ name }}");
char *result = templ_render(templ, vars);
if ( !status_is_error() ) {
os_file_write("name.html", result, os_strlen(result));
} else {
fprintf(stderr, "fehler aufgetreten in der übergebenen zeichenkette: %s\n", status_message());
status_reset();
}
}
fehlerbehandlung
eine tolerante fehlerbehandlung wurde in dieser version eingebaut. es kann der gesamte prozess der verarbeitung eines templates durchlaufen werden, ohne unvorhergesehene ergebnisse. zu jedem zeitpunkt kann auf fehlerstatus abgeprüft werden. es ist also nicht notwendig jeden aufruf der api in ein if
verpackt werden um fehler abzufangen.
codehygiene
mit hilfe der Codacy analyse wurde die codebasis bereinigt.