From be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 04:57:58 +0200 Subject: Adding upstream version 1.44.3. Signed-off-by: Daniel Baumann --- .../h2o/libh2o/misc/picotemplate/README.mkdn | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 web/server/h2o/libh2o/misc/picotemplate/README.mkdn (limited to 'web/server/h2o/libh2o/misc/picotemplate/README.mkdn') diff --git a/web/server/h2o/libh2o/misc/picotemplate/README.mkdn b/web/server/h2o/libh2o/misc/picotemplate/README.mkdn new file mode 100644 index 00000000..266f4bfa --- /dev/null +++ b/web/server/h2o/libh2o/misc/picotemplate/README.mkdn @@ -0,0 +1,42 @@ +PICOTEMPLATE - a tiny template engine for embedded HTML +======================================================= + +Picotemplate is a tiny template engine (preprocessor) designed to embed HTML (or other types of document) within the source code of any programming language. + +There are often cases where you would like to generate HTML within a program. In such cases, the easiest way would be to use a DSL (domain-specific language) to embed the HTML in the source code and preprocess it. Picotemplate is a preprocesser designed for such an use-case. + +As of now, Perl, C++, JavaScript, and JSX are the supported languages. + +THE LOGIC +--------- + +* lines starting with "?" are considered as embedded document +* within embedded document are considered as expressions (that return strings) +* the output is accumulated to variable named "_" (or $output in case of perl) +* filenames starting with an underscore (_) will be preprocessed, and the name of the output file will be the same omitting the leading underscore (e.g. _foo.cc will be preproccessed and converted to foo.cc) + +EXAMPLE +------- + +The following code (in _foo.cc) will be preprocessed and converted to a function (in foo.cc) that returns an function building an HTML snippet. + +``` +std::string unordered_list(const std::vector& strs) +{ + std::string _; // output is accumulated to _ +?
    + for (std::vector::const_iterator i = strs.begin(); + i != strs.end(); + ++i) { +?
  • + } +?
+ return _; +} +``` + +To preprocess a source file, simply run the command with the name of the source file to preprocess. The following exmaple preprocesses _foo.cc_ (template files should start with an underscore) and produces _foo.cc_. + +``` +$ picotemplate.pl _foo.cc +``` -- cgit v1.2.3