# htmltemplate A tiny html template 'engine'. It currently supports: - replacements of values. Via numbered or not-numbered parameters - loops inside the template file ### Example If you want an example with more explainations, consult `examples/02_with_comments.jai`. If you want to know what you else can do with the template syntax, look at the unit tests & comments in `test/test.jai`. HTML template: ```html
``` Code: ```text #import "Basic"; #import "htmltemplate"; main :: () { queue_action: [..]Action; defer array_free(queue_action); commit("foo1", "My Title"); commit("foo2", "#about", "target=\"_self\"", "About"); commit("foo3", "blog", "_self"); commit("foo4", .[ .["Foo", "Bar"], .["Fizz", "Buzz"], .["contact", ""], ]); success, html_string, exit_code, error_message := generate(queue_action, TEMPLATE, .STRING); defer { free(html_string); free(error_message); } if !success { log("%", error_message); return; } log("%", html_string); } ``` Output: ```html ``` ## Compiler Version ``` $ jai -version Version: beta 0.2.028, built on 9 April 2026. ``` ## Usage Put the library into your project-local `modules` dir, or where ever you defined your library path. ## Tests You can run unit tests with: `jai build.jai - run silent`. ## BNF ``` statement = "{{" ( replace | loop ) "}}" ; replace = ":" identifier ":" ( html_code )? ; loop = "loop" ":" identifier ":" html_code ; html_code = { UNICODE | replace_marks | escape_marks } ; replace_marks = "%" | "%" number ; escape_marks = "\%" ; identifier = UNICODE ; number = [1-9] ; ```