// // Template.h // // $Id$ // // Library: JSON // Package: JSON // Module: Template // // Definition of the Template class. // // Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // and Contributors. // // SPDX-License-Identifier: BSL-1.0 // #ifndef JSON_JSONTemplate_INCLUDED #define JSON_JSONTemplate_INCLUDED #include "Poco/JSON/JSON.h" #include "Poco/Dynamic/Var.h" #include "Poco/SharedPtr.h" #include "Poco/Path.h" #include "Poco/Timestamp.h" #include #include namespace Poco { namespace JSON { class MultiPart; POCO_DECLARE_EXCEPTION(JSON_API, JSONTemplateException, Poco::Exception) class JSON_API Template /// Template is a template engine which uses JSON as input /// for generating output. There are commands for /// looping over JSON arrays, include other templates, /// conditional output, etc. /// /// All text is send to the outputstream. A command is placed /// between /// /// ---- /// /// These are the available commands: /// /// /// ---- /// The result of the query is send to the output stream /// This command can also be written as /// /// /// ---- /// When the result of query is true, all the text between /// if and else (or endif when there is no else) is send to the /// output stream. When the result of query is false, all the text /// between else and endif is send to the output stream. An empty /// object, an empty array or a null value is considered as a false value. /// For numbers a zero is false. An empty String is also false. /// /// /// ---- /// This can be used to check the existence of the value. /// Use this for example when a zero value is ok (which returns false for . /// /// /// ---- /// The result of the query must be an array. For each element /// in the array the text between for and endfor is send to the /// output stream. The active element is stored in the variable. /// /// /// ---- /// Includes a template. When the filename is relative it will try /// to resolve the filename against the active template. When this /// file doesn't exist, it can still be found when the JSONTemplateCache /// is used. /// /// A query is passed to Poco::JSON::Query to get the value. { public: typedef SharedPtr