{"id":16669499,"url":"https://github.com/racke/template-flute","last_synced_at":"2025-03-21T17:32:40.598Z","repository":{"id":77143604,"uuid":"1429837","full_name":"racke/Template-Flute","owner":"racke","description":"Template::Flute - Modern designer-friendly HTML templating Engine","archived":false,"fork":false,"pushed_at":"2024-01-18T11:39:48.000Z","size":2577,"stargazers_count":11,"open_issues_count":37,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T03:22:25.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/racke.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-03-02T08:51:03.000Z","updated_at":"2024-01-18T11:39:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"71101229-f28d-42c8-9fd2-8500e3cb259f","html_url":"https://github.com/racke/Template-Flute","commit_stats":null,"previous_names":[],"tags_count":119,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racke%2FTemplate-Flute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racke%2FTemplate-Flute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racke%2FTemplate-Flute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racke%2FTemplate-Flute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/racke","download_url":"https://codeload.github.com/racke/Template-Flute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244838691,"owners_count":20518868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T11:33:11.997Z","updated_at":"2025-03-21T17:32:36.426Z","avatar_url":"https://github.com/racke.png","language":"Perl","readme":"NAME\n\n    Template::Flute - Modern designer-friendly HTML templating Engine\n\nVERSION\n\n    Version 0.027\n\nSYNOPSIS\n\n        use Template::Flute;\n    \n        my ($cart, $flute, %values);\n    \n        $cart = [{...},{...}];\n        $values{cost} = ...\n    \n        $flute = new Template::Flute(specification_file =\u003e 'cart.xml',\n                               template_file =\u003e 'cart.html',\n                               iterators =\u003e {cart =\u003e $cart},\n                               values =\u003e \\%values,\n                               autodetect =\u003e {\n                                              disable =\u003e [qw/Foo::Bar/],\n                                             }\n                               );\n    \n        print $flute-\u003eprocess();\n\nDESCRIPTION\n\n    Template::Flute enables you to completely separate web design and\n    programming tasks for dynamic web applications.\n\n    Templates are designed to be designer-friendly; there's no inline code\n    or mini templating language for your designers to learn - instead,\n    standard HTML and CSS classes are used, leading to HTML that can easily\n    be understood and edited by WYSIWYG editors and hand-coding designers\n    alike.\n\n    An example is easier than a wordy description:\n\n    Given the following template snippet:\n\n        \u003cdiv class=\"customer_name\"\u003eMr A Test\u003c/div\u003e\n        \u003cdiv class=\"customer_email\"\u003esomeone@example.com\u003c/div\u003e\n\n    and the following specification:\n\n       \u003cspecification name=\"example\" description=\"Example\"\u003e\n            \u003cvalue name=\"customer_name\" /\u003e\n            \u003cvalue name=\"email\" class=\"customer_email\" /\u003e\n        \u003c/specification\u003e\n\n    Processing the above as follows:\n\n        $flute = Template::Flute-\u003enew(\n            template_file      =\u003e 'template.html',\n            specification_file =\u003e 'spec.xml',\n        );\n        $flute-\u003eset_values({\n            customer_name =\u003e 'Bob McTest',\n            email =\u003e 'bob@example.com',\n        });;\n        print $flute-\u003eprocess;\n\n    The resulting output would be:\n\n        \u003cdiv class=\"customer_name\"\u003eBob McTest\u003c/div\u003e\n        \u003cdiv class=\"email\"\u003ebob@example.com\u003c/div\u003e\n\n    In other words, rather than including a templating language within your\n    templates which your designers must master and which could interfere\n    with previews in WYSIWYG tools, CSS selectors in the template are tied\n    to your data structures or objects by a specification provided by the\n    programmer.\n\n Workflow\n\n    The easiest way to use Template::Flute is to pass all necessary\n    parameters to the constructor and call the process method to generate\n    the HTML.\n\n    You can also break it down in separate steps:\n\n    1. Parse specification\n\n      Parse specification based on your specification format (e.g with\n      Template::Flute::Specification::XML or\n      Template::Flute::Specification::Scoped.).\n\n          $xml_spec = new Template::Flute::Specification::XML;\n          $spec = $xml_spec-\u003eparse(q{\u003cspecification name=\"cart\" description=\"Cart\"\u003e\n               \u003clist name=\"cart\" class=\"cartitem\" iterator=\"cart\"\u003e\n               \u003cparam name=\"name\" field=\"title\"/\u003e\n               \u003cparam name=\"quantity\"/\u003e\n               \u003cparam name=\"price\"/\u003e\n               \u003c/list\u003e\n               \u003cvalue name=\"cost\"/\u003e\n               \u003c/specification\u003e});\n\n    2. Parse template\n\n      Parse template with Template::Flute::HTML object.\n\n          $template = new Template::Flute::HTML;\n          $template-\u003eparse(q{\u003chtml\u003e\n              \u003chead\u003e\n              \u003ctitle\u003eCart Example\u003c/title\u003e\n              \u003c/head\u003e\n              \u003cbody\u003e\n              \u003ctable class=\"cart\"\u003e\n              \u003ctr class=\"cartheader\"\u003e\n              \u003cth\u003eName\u003c/th\u003e\n              \u003cth\u003eQuantity\u003c/th\u003e\n              \u003cth\u003ePrice\u003c/th\u003e\n              \u003c/tr\u003e\n              \u003ctr class=\"cartitem\"\u003e\n              \u003ctd class=\"name\"\u003eSample Book\u003c/td\u003e\n              \u003ctd\u003e\u003cinput class=\"quantity\" name=\"quantity\" size=\"3\" value=\"10\"\u003e\u003c/td\u003e\n              \u003ctd class=\"price\"\u003e$1\u003c/td\u003e\n              \u003c/tr\u003e\n              \u003ctr class=\"cartheader\"\u003e\u003cth colspan=\"2\"\u003e\u003c/th\u003e\u003cth\u003eTotal\u003c/th\u003e\n              \u003c/tr\u003e\n              \u003ctr\u003e\n              \u003ctd colspan=\"2\"\u003e\u003c/td\u003e\u003ctd class=\"cost\"\u003e$10\u003c/td\u003e\n              \u003c/tr\u003e\n              \u003c/table\u003e\n              \u003c/body\u003e\u003c/html\u003e},\n              $spec);\n\n    3. Produce HTML output\n\n          $flute = new Template::Flute(template =\u003e $template,\n                                     iterators =\u003e {cart =\u003e $cart},\n                                     values =\u003e {cost =\u003e '84.94'});\n          $flute-\u003eprocess();\n\nCONSTRUCTOR\n\n new\n\n    Create a Template::Flute object with the following parameters:\n\n    specification_file\n\n      Specification file name.\n\n    specification_parser\n\n      Select specification parser. This can be either the full class name\n      like MyApp::Specification::Parser or the last part for classes\n      residing in the Template::Flute::Specification namespace.\n\n    specification\n\n      Specification object or specification as string.\n\n    template_file\n\n      HTML template file.\n\n    template\n\n      Template::Flute::HTML object or template as string.\n\n    filters\n\n      Hash reference of filter functions.\n\n    i18n\n\n      Template::Flute::I18N object.\n\n    translate_attributes\n\n      An arrayref of attribute names to translate. If the name has a dot,\n      it is interpreted as tagname + attribute, so placeholder\" will\n      unconditionally translate all the placeholders, while\n      input.placeholder only the placeholder found on the input tag.\n\n      Additional dotted values compose conditions for attributes. E.g.\n      input.value.type.submit means all the value attributes with attribute\n      type set to submit.\n\n      Defaults to ['input.value.type.submit', 'placeholder']\n\n    iterators\n\n      Hash references of iterators.\n\n    values\n\n      Hash reference of values to be used by the process method.\n\n    auto_iterators\n\n      Builds iterators automatically from values.\n\n    autodetect\n\n      A configuration option. It should be an hashref with a key disable\n      and a value with an arrayref with a list of classes for objects which\n      should be considered plain hashrefs instead. Example:\n\n        my $flute = Template::Flute-\u003enew(....\n                                         autodetect =\u003e { disable =\u003e [qw/My::Object/] },\n                                         ....\n                                        );\n\n      Doing so, if you pass a value holding a My::Object object, and you\n      have a specification with something like this:\n\n        \u003cspecification\u003e\n         \u003cvalue name=\"name\" field=\"object.method\"/\u003e\n        \u003c/specification\u003e\n\n      The value will be $object-{method}\u003e, not $object-$method\u003e.\n\n      The object is checked with isa.\n\n      Classical example: Dancer::Session::Abstract.\n\n    uri\n\n      Base URI for your template. This adjusts the links in the HTML tags\n      a, base, img, link and script.\n\n    email_cids\n\n      This is meant to be used on HTML emails. When this is set to an hash\n      reference (which should be empty), the hash will be populated with\n      the following values:\n\n        cid1 =\u003e { filename =\u003e 'foo.png' },\n        cid2 =\u003e { filename =\u003e 'foo2.gif' },\n\n      and in the body the images src attribute will be replaced with\n      cid:cid1.\n\n      The cid names are arbitrary and assigned by the template. The code\n      should look at the reference values which were modified.\n\n    cids\n\n      Optional hashref with options for the CID replacement behaviour.\n\n      By default, if the source looks like an HTTP/HTTPS URI, the image\n      source is not altered and no CID is assigned.\n\n      If you pass a base_url value in this hashref, the URI matching it\n      will be converted to cids and the rest of the path will be added to\n      the email_cids hashref.\n\n      Example:\n\n          my $cids = {};\n          $flute = Template::Flute-\u003enew(template =\u003e $template,\n                                        specification =\u003e $spec,\n                                        email_cids =\u003e $cids,\n                                        cids =\u003e {\n                                                 base_url =\u003e 'http://example.com/'\n                                                });\n\n      Say the template contains images with source\n      http://example.com/image.png, the email_cids hashref will contain a\n      cid with filename \"image.png\".\n\nMETHODS\n\n BUILD\n\n    Force creation of template class as soon as object is instantiated.\n\n process [HASHREF]\n\n    Processes HTML template, manipulates the HTML tree based on the\n    specification, values and iterators.\n\n    Returns HTML output.\n\n process_template\n\n    Processes HTML template and returns Template::Flute::HTML object.\n\n filter ELEMENT VALUE\n\n    Runs the filter used by ELEMENT on VALUE and returns the result.\n\n value NAME\n\n    Returns the value for NAME.\n\n set_values HASHREF\n\n    Sets hash reference of values to be used by the process method. Same as\n    passing the hash reference as values argument to the constructor.\n\n template\n\n    Returns HTML template object, see Template::Flute::HTML for details.\n\n specification\n\n    Returns specification object, see Template::Flute::Specification for\n    details.\n\n patterns\n\n    Returns all patterns found in the specification.\n\n scopes\n\nSPECIFICATION\n\n    The specification ties the elements in the HTML template to the data\n    (variables, lists, forms) which is added to the template.\n\n    The default format for the specification is XML implemented by the\n    Template::Flute::Specification::XML module. You can use the\n    Config::Scoped format implemented by\n    Template::Flute::Specification::Scoped module or write your own\n    specification parser class.\n\n COMMON ATTRIBUTES\n\n    Common attributes for specification elements are:\n\n    name\n\n      Name of element.\n\n          \u003cvalue name=\"dancefloor\"/\u003e\n\n    class\n\n      Class of corresponding elements in the HTML template.\n\n          \u003cvalue name=\"dancefloor\" class=\"dancefloor-link\"/\u003e\n\n      If this attribute is omitted, the value of the name attribute is used\n      to relate to the class in the HTML template.\n\n    id\n\n      Id of corresponding element in the HTML template. Overrides the class\n      attribute for the specification element.\n\n         \u003cvalue name=\"dancefloor\" id=\"dancefloor-link\"/\u003e\n\n    target\n\n      HTML attribute to fill the value instead of replacing the body of the\n      HTML element.\n\n         \u003cvalue name=\"dancefloor\" class=\"dancefloor-link\" target=\"href\"/\u003e\n\n    joiner\n\n      String placed between the text and the appended value. The joiner\n      isn't added if the value is empty.\n\n ELEMENTS\n\n    Possible elements in the specification are:\n\n    container\n\n      The first container is only shown in the output if the value\n      billing_address is set:\n\n        \u003ccontainer name=\"billing\" value=\"billing_address\" class=\"billingWrapper\"\u003e\n        \u003c/container\u003e\n\n      The second container is shown if the value warnings or the value\n      errors is set:\n\n        \u003ccontainer name=\"account_errors\" value=\"warnings|errors\" class=\"infobox\"\u003e\n        \u003cvalue name=\"warnings\"/\u003e\n        \u003cvalue name=\"errors\"/\u003e\n        \u003c/container\u003e\n\n    list\n\n    separator\n\n      Separator elements for list are added after any list item in the\n      output with the exception of the last one.\n\n      Example specification, HTML template and output:\n\n        \u003cspecification\u003e\n        \u003clist name=\"list\" iterator=\"tokens\"\u003e\n        \u003cparam name=\"key\"/\u003e\n        \u003cseparator name=\"sep\"/\u003e\n        \u003c/list\u003e\n        \u003c/specification\u003e\n      \n        \u003cdiv class=\"list\"\u003e\u003cspan class=\"key\"\u003eKEY\u003c/span\u003e\u003c/div\u003e\u003cspan class=\"sep\"\u003e | \u003c/span\u003e\n      \n        \u003cdiv class=\"list\"\u003e\u003cspan class=\"key\"\u003eFOO\u003c/span\u003e\u003c/div\u003e\u003cspan class=\"sep\"\u003e | \u003c/span\u003e\n        \u003cdiv class=\"list\"\u003e\u003cspan class=\"key\"\u003eBAR\u003c/span\u003e\u003c/div\u003e\n\n    param\n\n      Param elements are replaced with the corresponding value from the\n      list iterator.\n\n      The following operations are supported for param elements:\n\n      append\n\n\tAppends the param value to the text found in the HTML template.\n\n      prepend\n\n\tPrepends the param value to the text found in the HTML template.\n\n      target\n\n\tThe attribute to operate on. See below target for value for\n\tdetails.\n\n      toggle\n\n\tWhen the args attribute is set to tree, it doesn't interpolate\n\tanything and just shows corresponding HTML element if param value\n\tis set.\n\n\tWith target attribute, it simply toggles the target attribute.\n\n\tOtherwise, if value is true, shows the HTML element and set its\n\tcontent to the value. If value is false, removes the HTML element.\n\n\tSo, if your element has children elements, you probably want to use\n\tthe args=\"tree\" attribute (see below for an example).\n\n      Other attributes for param elements are:\n\n      filter\n\n\tApplies filter to param value.\n\n      increment\n\n\tUses value from increment instead of a value from the iterator.\n\n            \u003cparam name=\"pos\" increment=\"1\"\u003e\n\n    value\n\n      Value elements are replaced with a single value present in the values\n      hash passed to the constructor of this class or later set with the\n      set_values method.\n\n      The following operations are supported for value elements:\n\n      append\n\n\tAppends the value to the text found in the HTML template.\n\n      prepend\n\n\tPrepends the value to the text found in the HTML template.\n\n      hook\n\n\tInsert HTML residing in value as subtree of the corresponding HTML\n\telement. HTML will be parsed with XML::Twig. See \"INSERT HTML\" for\n\tan example.\n\n      keep\n\n\tPreserves the text inside of the HTML element if value is false in\n\tthe Perl sense.\n\n      toggle\n\n\tOnly shows corresponding HTML element if value is set.\n\n      Other attributes for value elements are:\n\n      target\n\n\tSpecify the attribute to operate on instead of the tag content. It\n\tcan be a named attribute (e.g., href), the wildcard character(*,\n\tmeaning all the attributes found in the HTML template), or a comma\n\tseparated list (e.g., alt,title).\n\n      filter\n\n\tApplies filter to value.\n\n      include\n\n\tProcesses the template file named in this attribute. This implies\n\tthe hook operation. See \"INCLUDE FILES\" for more information.\n\n    form\n\n      Form elements are tied through specification to HTML forms.\n      Attributes for form elements in addition to class and id are:\n\n      link\n\n\tThe link attribute can only have the value name and allows to base\n\tthe relationship between form specification elements and HTML form\n\ttags on the name HTML attribute instead of class, which is usually\n\tmore convenient.\n\n    input\n\n    filter\n\n    sort\n\n    i18n\n\n    skip\n\n      This attribute (which can be provided to param or value specification\n      elements) supports the following values:\n\n      empty\n\n\tDo not replace the template string if the value or parameter is\n\tundefined, empty or just whitespace.\n\n\tE.g.\n\n         \u003cvalue name=\"cartline\" skip=\"empty\"/\u003e\n         \u003clist name=\"items\" iterator=\"items\"\u003e\n           \u003cparam name=\"category\" skip=\"empty\"/\u003e\n         \u003c/list\u003e\n\n    pattern\n\n      You can define patterns in your specification to interpolate the\n      strings instead of replacing them.\n\n      A pattern is defined by the attributes name and type and its content.\n      type can be only string or regexp.\n\n      The interpolation happens if the value and param elements of the\n      specification have an attribute pattern set with the pattern's name.\n\n      Given this HTML:\n\n       \u003cp class=\"cartline\"\u003eThere are 123 items in your shopping cart.\u003c/p\u003e\n       \u003cul\u003e\n         \u003cli class=\"items\"\u003e\n           \u003cspan class=\"number\"\u003e1\u003c/span\u003e\n           \u003cspan class=\"category\"\u003ein category 123\u003c/span\u003e\n         \u003c/li\u003e\n       \u003c/ul\u003e\n\n      And this specification:\n\n       \u003cspecification\u003e\n       \u003cpattern name=\"pxt\" type=\"string\"\u003e123\u003c/pattern\u003e\n       \u003clist name=\"items\" iterator=\"items\"\u003e\n         \u003cparam name=\"number\"/\u003e\n         \u003cparam name=\"category\" pattern=\"pxt\"/\u003e\n       \u003c/list\u003e\n       \u003cvalue name=\"cartline\" pattern=\"pxt\"/\u003e\n       \u003c/specification\u003e\n\n      In this example, in the cartline and category classes' text, only the\n      template text \"123\" will be replaced by the value, not the whole\n      element content, yielding such output:\n\n       \u003cp class=\"cartline\"\u003eThere are 42 items in your shopping cart.\u003c/p\u003e\n       \u003cul\u003e\n        \u003cli class=\"items\"\u003e\n         \u003cspan class=\"number\"\u003e1\u003c/span\u003e\n         \u003cspan class=\"category\"\u003ein category tofu\u003c/span\u003e\n        \u003c/li\u003e\n        \u003cli class=\"items\"\u003e\n         \u003cspan class=\"number\"\u003e2\u003c/span\u003e\n         \u003cspan class=\"category\"\u003ein category pizza\u003c/span\u003e\n        \u003c/li\u003e\n       \u003c/ul\u003e\n\n      Note: All matches of the pattern are subject to replacement, starting\n      with version 0.025.\n\nSIMPLE OPERATORS\n\n append\n\n    Appends the value to the text inside a HTML element or to an attribute\n    if target has been specified. This can be used in value and param\n    specification elements.\n\n    The example shows how to add a HTML class to elements in a list:\n\n    HTML:\n\n        \u003cul class=\"nav-sub\"\u003e\n            \u003cli class=\"category\"\u003e\u003ca href=\"\" class=\"catname\"\u003eMedicine\u003c/a\u003e\u003c/li\u003e\n        \u003c/ul\u003e\n\n    XML:\n\n        \u003cspecification\u003e\n            \u003clist name=\"category\" iterator=\"categories\"\u003e\n                \u003cparam name=\"name\" class=\"catname\"/\u003e\n                \u003cparam name=\"catname\" field=\"uri\" target=\"href\"/\u003e\n                \u003cparam name=\"css\" class=\"catname\" target=\"class\" op=\"append\" joiner=\" \"/\u003e\n            \u003c/list\u003e\n        \u003c/specification\u003e\n\nCONTAINERS\n\n    Conditional processing like IF or ELSE is done with the help of\n    containers.\n\n Display image only if present\n\n    In this example we want to show an image only on a certain condition:\n\n    HTML:\n\n        \u003cspan class=\"banner-box\"\u003e\n            \u003cimg class=\"banner\" src=\"\"/\u003e\n        \u003c/span\u003e\n\n    XML:\n\n        \u003ccontainer name=\"banner-box\" value=\"banner\"\u003e\n            \u003cvalue name=\"banner\" target=\"src\"/\u003e\n        \u003c/container\u003e\n\n    Source code:\n\n        if ($organization eq 'Big One') {\n            $values{banner} = 'banners/big_one.png';\n        }\n\n Display link in a list only if present\n\n    In this example we want so show a link only if an URL is available:\n\n    HTML:\n\n        \u003cdiv class=\"linklist\"\u003e\n            \u003cspan class=\"name\"\u003eName\u003c/span\u003e\n            \u003cdiv class=\"link\"\u003e\n                \u003ca href=\"#\" class=\"url\"\u003eGoto ...\u003c/a\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n    XML:\n\n        \u003cspecification name=\"link\"\u003e\n            \u003clist name=\"links\" class=\"linklist\" iterator=\"links\"\u003e\n                \u003cparam name=\"name\"/\u003e\n                \u003cparam name=\"url\" target=\"href\"/\u003e\n                \u003ccontainer name=\"link\" class=\"link\" value=\"url\"/\u003e\n            \u003c/list\u003e\n        \u003c/specification\u003e\n\n    Source code:\n\n       @records = ({name =\u003e 'Link', url =\u003e 'http://localhost/'},\n                   {name =\u003e 'No Link'},\n                   {name =\u003e 'Another Link', url =\u003e 'http://localhost/'},\n                  );\n    \n       $flute = Template::Flute-\u003enew(specification =\u003e $spec_xml,\n                                     template =\u003e $template,\n                                     iterators =\u003e {links =\u003e \\@records});\n    \n       $output = $flute-\u003eprocess();\n\nITERATORS\n\n    Template::Flute uses iterators to retrieve list elements and insert\n    them into the document tree. This abstraction relieves us from worrying\n    about where the data actually comes from. We basically just need an\n    array of hash references and an iterator class with a next and a count\n    method. For your convenience you can create an iterator from\n    Template::Flute::Iterator class very easily.\n\n DROPDOWNS\n\n    Iterators can be used for dropdowns (HTML \u003cselect\u003e elements) as well.\n\n    Template:\n\n        \u003cselect class=\"color\"\u003e\u003c/select\u003e\n\n    Specification:\n\n        \u003cvalue name=\"color\" iterator=\"colors\"/\u003e\n\n    Code:\n\n        @colors = ({value =\u003e 'red', label =\u003e 'Red'},\n                   {value =\u003e 'black', label =\u003e 'Black'});\n    \n        $flute = Template::Flute-\u003enew(template =\u003e $html,\n                                  specification =\u003e $spec,\n                                  iterators =\u003e {colors =\u003e \\@colors},\n                                  values =\u003e {color =\u003e 'black'},\n                                 );\n\n    HTML output:\n\n          \u003cselect class=\"color\"\u003e\n          \u003coption value=\"red\"\u003eRed\u003c/option\u003e\n          \u003coption value=\"black\" selected=\"selected\"\u003eBlack\u003c/option\u003e\n          \u003c/select\u003e\n\n  Default value for dropdowns\n\n    You can specify the dropdown item which is selected by default with the\n    iterator_default) attribute.\n\n    Template:\n\n        \u003cselect class=\"color\"\u003e\u003c/select\u003e\n\n    Specification:\n\n        \u003cvalue name=\"color\" iterator=\"colors\" iterator_default=\"black\"/\u003e\n\n    Code:\n\n        @colors = ({value =\u003e 'red', label =\u003e 'Red'},\n                   {value =\u003e 'black', label =\u003e 'Black'});\n    \n        $flute = Template::Flute-\u003enew(template =\u003e $html,\n                                  specification =\u003e $spec,\n                                  iterators =\u003e {colors =\u003e \\@colors},\n                                 );\n\n    HTML output:\n\n          \u003cselect class=\"color\"\u003e\n          \u003coption value=\"red\"\u003eRed\u003c/option\u003e\n          \u003coption value=\"black\" selected=\"selected\"\u003eBlack\u003c/option\u003e\n          \u003c/select\u003e\n\n  Custom iterators for dropdowns\n\n    By default, the iterator for a dropdown is an arrayref of hashrefs with\n    two hardcoded keys: value and (optionally) label. You can override this\n    behaviour in the specification with iterator_value_key and\n    iterator_name_key to use your own hashref's keys from the iterator,\n    instead of value and label.\n\n    Specification:\n\n      \u003cspecification\u003e\n        \u003cvalue name=\"color\" iterator=\"colors\"\n               iterator_value_key=\"code\" iterator_name_key=\"name\"/\u003e\n      \u003c/specification\u003e\n\n    Template:\n\n      \u003chtml\u003e\n       \u003cselect class=\"color\"\u003e\n       \u003coption value=\"example\"\u003eExample\u003c/option\u003e\n       \u003c/select\u003e\n      \u003c/html\u003e\n\n    Code:\n\n      @colors = ({code =\u003e 'red', name =\u003e 'Red'},\n                 {code =\u003e 'black', name =\u003e 'Black'},\n                );\n    \n      $flute = Template::Flute-\u003enew(template =\u003e $html,\n                                    specification =\u003e $spec,\n                                    iterators =\u003e {colors =\u003e \\@colors},\n                                    values =\u003e { color =\u003e 'black' },\n                                   );\n    \n      $out = $flute-\u003eprocess();\n\n    Output:\n\n      \u003chtml\u003e\n       \u003chead\u003e\u003c/head\u003e\n       \u003cbody\u003e\n        \u003cselect class=\"color\"\u003e\n         \u003coption value=\"red\"\u003eRed\u003c/option\u003e\n         \u003coption selected=\"selected\" value=\"black\"\u003eBlack\u003c/option\u003e\n        \u003c/select\u003e\n       \u003c/body\u003e\n      \u003c/html\u003e\n\n  Limit lists\n\n    Sometimes you may wish to limit the number or iterations through you\n    list.\n\n    Specification:\n\n        \u003cspecification\u003e\n            \u003clist name=\"images\" iterator=\"images\" limit=\"1\"\u003e\n                \u003cparam name=\"image\" target=\"src\" field=\"image_url\" /\u003e\n            \u003c/list\u003e\n        \u003c/specification\u003e\n\n    Template:\n\n        \u003cdiv class=\"images\"\u003e\n            \u003cimg class=\"image\" src=\"/images/bottle.jpg\" /\u003e\n        \u003c/div\u003e\n\n    Code:\n\n        $images = [\n            { image_url =\u003e '/images/bottle1.jpg' },\n            { image_url =\u003e '/images/bottle2.jpg' },\n            { image_url =\u003e '/images/bottle3.jpg' },\n        ];\n    \n        $flute = Template::Flute-\u003enew(\n            template      =\u003e $html,\n            specification =\u003e $spec,\n            values        =\u003e { images =\u003e $images },\n        );\n    \n        $out = $flute-\u003eprocess;\n\n    Output:\n\n        \u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\n            \u003cdiv class=\"images\"\u003e\n                \u003cimg class=\"image\" src=\"/images/bottle1.jpg\" /\u003e\n            \u003c/div\u003e\n        \u003c/body\u003e\u003c/html\u003e\n\nLISTS\n\n    Lists can be accessed after parsing the specification and the HTML\n    template through the HTML template object:\n\n        $flute-\u003etemplate-\u003elists();\n    \n        $flute-\u003etemplate-\u003elist('cart');\n\n    Only lists present in the specification and the HTML template can be\n    addressed in this way.\n\n    See Template::Flute::List for details about lists.\n\nOBJECTS AND STRUCTURES\n\n    You can pass objects and hashrefs as values. To access a key or an\n    accessor, you have to use a dotted notation with field. An example for\n    both hashrefs and objects follows.\n\n    Specification:\n\n      \u003cspecification\u003e\n       \u003cvalue name=\"object\" field=\"myobject.method\" /\u003e\n       \u003cvalue name=\"struct\" field=\"mystruct.key\" /\u003e\n      \u003c/specification\u003e\n\n    HTML:\n\n      \u003chtml\u003e\n        \u003cbody\u003e\n          \u003cspan class=\"object\"\u003eWelcome back!\u003c/span\u003e\n          \u003cspan class=\"struct\"\u003eAnother one\u003c/span\u003e\n        \u003c/body\u003e\n      \u003c/html\u003e\n\n    Code:\n\n      package My::Object;\n      sub new {\n          my $class = shift;\n          bless {}, $class;\n      }\n      sub method {\n          return \"Hello from the method\";\n      }\n      package main;\n      my $flute = Template::Flute-\u003enew(\n          specification =\u003e $spec,\n          template =\u003e $html,\n          values =\u003e {\n              myobject =\u003e My::Object-\u003enew,\n              mystruct =\u003e { key =\u003e \"Hello from hash\" },\n             }\n         );\n\n    process will return:\n\n      \u003chtml\u003e\n        \u003chead\u003e\u003c/head\u003e\n        \u003cbody\u003e\n          \u003cspan class=\"object\"\u003eHello from the method\u003c/span\u003e\n          \u003cspan class=\"struct\"\u003eHello from hash\u003c/span\u003e\n        \u003c/body\u003e\n      \u003c/html\u003e\n\n    Sometimes you need to treat an object like an hashref. How to do that\n    is explained under the autodetect option for the constructor.\n\nFORMS\n\n    Forms can be accessed after parsing the specification and the HTML\n    template through the HTML template object:\n\n        $flute-\u003etemplate-\u003eforms();\n    \n        $flute-\u003etemplate-\u003eform('edit_content');\n\n    Only forms present in the specification and the HTML template can be\n    addressed in this way.\n\n    See Template::Flute::Form for details about forms.\n\nFILTERS\n\n    Filters are used to change the display of value and param elements in\n    the resulting HTML output:\n\n        \u003cvalue name=\"billing_address\" filter=\"eol\"/\u003e\n    \n        \u003cparam name=\"price\" filter=\"currency\"/\u003e\n\n    The following filters are included:\n\n    upper\n\n      Uppercase filter, see Template::Flute::Filter::Upper.\n\n    strip\n\n      Strips whitespace at the beginning at the end, see\n      Template::Flute::Filter::Strip.\n\n    eol\n\n      Filter preserving line breaks, see Template::Flute::Filter::Eol.\n\n    nobreak_single\n\n      Filter replacing missing text with no-break space, see\n      Template::Flute::Filter::NobreakSingle.\n\n    currency\n\n      Currency filter, see Template::Flute::Filter::Currency. Requires\n      Number::Format module.\n\n    date\n\n      Date filter, see Template::Flute::Filter::Date. Requires DateTime and\n      DateTime::Format::ISO8601 modules.\n\n    country_name\n\n      Country name filter, see Template::Flute::Filter::CountryName.\n      Requires Locales module.\n\n    language_name\n\n      Language name filter, see Template::Flute::Filter::LanguageName.\n      Requires Locales module.\n\n    json_var\n\n      JSON to Javascript variable filter, see\n      Template::Flute::Filter::JsonVar. Requires JSON module.\n\n    lower_dash\n\n      Replaces spaces with dashes (-) and makes lowercase. see\n      Template::Flute::Filter::LowerDash.\n\n    markdown\n\n      Turns text in Markdown format into HTML. see\n      Template::Flute::Filter::Markdown.\n\n      Requires Text::Markdown and HTML::Scrubber modules.\n\n    Filter classes are loaded at runtime for efficiency and to keep the\n    number of dependencies for Template::Flute as small as possible.\n\n    See above for prerequisites needed by the included filter classes.\n\n Chained Filters\n\n    Filters can also be chained:\n\n        \u003cvalue name=\"note\" filter=\"upper eol\"/\u003e\n\n    Example template:\n\n        \u003cdiv class=\"note\"\u003e\n            This is a note.\n        \u003c/div\u003e\n\n    With the following value:\n\n        Update now!\n        Avoid security hazards!\n\n    The HTML output would look like:\n\n        \u003cdiv class=\"note\"\u003e\n        UPDATE NOW!\u003cbr /\u003e\n        AVOID SECURITY HAZARDS!\n        \u003c/div\u003e\n\nINSERT HTML AND INCLUDE FILES\n\n INSERT HTML\n\n    HTML can be generated in the code or retrieved from a database and\n    inserted into the template through the hook operation:\n\n        \u003cvalue name=\"description\" op=\"hook\"/\u003e\n\n    The result replaces the inner HTML of the following div tag:\n\n        \u003cdiv class=\"description\"\u003e\n            Sample content\n        \u003c/div\u003e\n\n INCLUDE FILES\n\n    Files, especially components for web pages can be processed and\n    included through value elements with the include attribute:\n\n        \u003cvalue name=\"sidebar\" include=\"component.html\"/\u003e\n\n    The result replaces the inner HTML of the following div tag:\n\n        \u003cdiv class=\"sidebar\"\u003e\n            Sample content\n        \u003c/div\u003e\n\nINSTALLATION\n\n    Template::Flute can be installed from the latest release on CPAN, or if\n    you wish for the very latest version, you can also install from the\n    sources on GitHub.\n\n FROM CPAN\n\n    To install from CPAN, simply use the cpanm utility:\n\n        $ cpanm Template::Flute\n\n FROM SOURCE\n\n    To install from source, first clone the repository, install the\n    required dependencies, and build:\n\n        $ git clone https://github.com/racke/Template-Flute\n        $ cd Template-Flute\n        $ cpanm --installdeps .\n        $ perl Makefile.PL\n        $ make\n        $ make test     # optional, but still a good idea\n        $ make install\n\nAUTHOR\n\n    Stefan Hornburg (Racke), \u003cracke@linuxia.de\u003e\n\nBUGS\n\n    Please report any bugs or feature requests at\n    https://github.com/racke/Template-Flute/issues.\n\nSUPPORT\n\n    You can find documentation for this module with the perldoc command.\n\n        perldoc Template::Flute\n\n    You can also look for information at:\n\n      * AnnoCPAN: Annotated CPAN documentation\n\n      http://annocpan.org/dist/Template-Flute\n\n      * CPAN Ratings\n\n      http://cpanratings.perl.org/d/Template-Flute\n\n      * Search CPAN\n\n      http://search.cpan.org/dist/Template-Flute/\n\nACKNOWLEDGEMENTS\n\n    Thanks to Nitish Bezzala (GH #157).\n\n    Thanks to Mohammad S Anwar (GH #156).\n\n    Thanks to Paul Cochrane for his tremendous amount of pull requests\n    issued during the GitHub challenge.\n\n    Thanks to Peter Mottram (GH #81, #87).\n\n    Thanks to William Carr (GH #86, #91).\n\n    Thanks to David Precious (bigpresh) for writing a much clearer\n    introduction for Template::Flute.\n\n    Thanks to Grega Pompe for proper implementation of nested lists and a\n    documentation fix.\n\n    Thanks to Jeff Boes for spotting a typo in the documentation of the\n    Template::Flute::Filter::JsonVar class.\n\n    Thanks to Ton Verhagen for being a big supporter of my projects in all\n    aspects.\n\n    Thanks to Sam Batschelet (GH #14, #93).\n\n    Thanks to Terrence Brannon for spotting a documentation mix-up.\n\nHISTORY\n\n    Template::Flute was initially named Template::Zoom. I renamed the\n    module because of a request from Matt S. Trout, author of the\n    HTML::Zoom module.\n\nLICENSE AND COPYRIGHT\n\n    Copyright 2010-2021 Stefan Hornburg (Racke) \u003cracke@linuxia.de\u003e.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the terms of either: the GNU General Public License as published\n    by the Free Software Foundation; or the Artistic License.\n\n    See http://dev.perl.org/licenses/ for more information.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fracke%2Ftemplate-flute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fracke%2Ftemplate-flute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fracke%2Ftemplate-flute/lists"}