{"id":18016980,"url":"https://github.com/fitzgen/tempest","last_synced_at":"2025-10-28T06:04:33.620Z","repository":{"id":630709,"uuid":"271460","full_name":"fitzgen/tempest","owner":"fitzgen","description":"Tempest jQuery Templating Plugin","archived":false,"fork":false,"pushed_at":"2010-10-04T18:22:49.000Z","size":201,"stargazers_count":22,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-21T00:32:38.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://fitzgeraldnick.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-08-07T08:30:45.000Z","updated_at":"2020-08-15T16:06:21.000Z","dependencies_parsed_at":"2022-08-16T10:31:23.038Z","dependency_job_id":null,"html_url":"https://github.com/fitzgen/tempest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fitzgen/tempest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Ftempest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Ftempest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Ftempest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Ftempest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/tempest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Ftempest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281391792,"owners_count":26492905,"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","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-30T04:19:51.397Z","updated_at":"2025-10-28T06:04:33.605Z","avatar_url":"https://github.com/fitzgen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"THIS PROJECT IS DEPRECATED\n==========================\n\nJQuery now has an officially sanctioned templating engine: http://blog.jquery.com/2010/10/04/new-official-jquery-plugins-provide-templating-data-linking-and-globalization/\n\nDevelopment on this project has now ceased.\n\nTempest jQuery Templating Plugin\n================================\n\nCopyright (c) 2009 Nick Fitzgerald - http://fitzgeraldnick.com/ - MIT licensed\n\nNote: All releases are minified, to get the latest development version grab a\nclone from http://github.com/fitzgen/tempest/tree/master\n\nHELLO WORLD\n===========\n\n    var template = \"\u003cp\u003eHello, {{ name }}!\u003c/p\u003e\";\n    $(document).tempest(template, {\n        name: \"World\"\n    });\n\nPHILOSOPHY\n==========\n\nI was not satisfied with the other templating plugins available, so I wrote my\nown. This templating system is very simple and enforces the seperation of form\nand function, or HTML and JS. This provides a great abstraction layer so that\nyou can write a template ad then promptly remove the mental overhead of\nrendering js objects to HTML.\n\nOther templating languages just build and execute function blocks with\nstrings. Any type of js logic you could want is included and evaluated. For some\npeople, this may be the freedom that they want.\n\nOn the other hand, Tempest will only fill in values and iterate over arrays for\nyou. This forces you to remove any programming logic from the templates and\nseparate form from function. This type of templating philosophy can also be seen\nin the Django templating language.\n\nThe other big thing, for me, is that iteration is handled seamlessly. Just pass\nan array of objects to tempest instead of a single object and it will return a\njquery element array.\n\nMAILING LIST\n============\n\nTo get involved, ask questions, or recieve help with Tempest, you can email the\nTempest mailing list: **tempest@librelist.com**\n\nAPI\n===\n\nNote: The API is for the most current release only, there may be slight\ndifferences in older releases.\n\nSaving \u0026 retrieving templates to and from $.tempest\n---------------------------------------------------\n\nSetter:\n\n    $.tempest(\"post\", \"\u003cli\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\");\n    // returns string: \"\u003cli\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\"\n\nGetter:\n\n    $.tempest(\"post\");\n    // returns string: \"\u003cli\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\"\n\n\n$.tempest will also find all elements with the class \"tempest-template\" and save\nthem with their \"title\" attribute as the key they are indexed by once the\n$(document).ready() event fires.\n\nFor example, assuming this is in the html when $(document).ready() fires:\n\n    \u003ctextarea title=\"new-post\" class=\"tempest-template\" style=\"display:none\"\u003e\n        \u003cli class='new'\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\n    \u003c/textarea\u003e\n\nThen you could access that template just as you would access any other template\nthat you manually created:\n\n    $.tempest(\"new-post\");\n    // returns string: \"\u003cli class='new'\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\"\n\nThe two typical elements people use as embedded templates are textareas and\nscripts with wacky types (for example \u003cscript type=\"text/template\"\u003e, which won't\nbe modified by browsers or attempted to be ran as JS). The reason these are\ntypically used is that search engines don't index the content inside these two\nelements.\n\nNote: $.tempest will remove the textarea from the DOM after storing the contents\nin the template cache.\n\nGet all templates Tempest has stored by passing no arguments:\n\n    $.tempest();\n    // returns array of pairs: [\n    //                           [\"post\",\n    //                            \"\u003cli\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\"],\n    //                           [\"new-post\",\n    //                            \"\u003cli class='new'\u003e\u003ca href='{{ url }}'\u003e{{ title }}\u003c/a\u003e\u003c/li\u003e\"]\n    //                         ]\n\nRendering objects to templates\n------------------------------\n\nRender an object to an existing template:\n\n    $.tempest(\"post\", {\n        title: \"My Blog\",\n        url: \"http://fitzgeraldnick.com/weblog/\",\n    });\n    // returns jQuery: [ \u003cli\u003e\u003ca href='http://fitzgeraldnick.com/weblog/'\u003eMy Blog\u003c/a\u003e\u003c/li\u003e ]\n\nRender an array of objects to an existing template\n\n    var arr = [{ title: \"My Blog\", url: \"http://fitzgeraldnick.com/weblog/\" },\n               { title: \"Google\", url: \"http://google.com/\" },\n               { title: \"Hacker News\", url: \"http://news.ycombinator.com/\" }];\n    $.tempest(\"post\", arr);\n    // returns jQuery: [ \u003cli\u003e, \u003cli\u003e, \u003cli\u003e ]\n\nRender an object (or array of objects) to a one-time-use template:\n\n    var one-time-template = \"\u003cspan\u003e{{ title }}: {{ content }}\u003c/span\u003e\";\n    $.tempest(one-time-template, {\n        \"title\": \"Example\",\n        \"content\": \"Hello World!\",\n    });\n    // returns jQuery: [ \u003cspan\u003eExample: Hello World!\u003c/span\u003e ]\n\nBoolean Logic\n-------------\n\nTempest implements very simple boolean logic. Just if's, no else's:\n\n    var template = \"{% if is_active %}\u003cp\u003eThis record is active.\u003c/p\u003e{% endif %}\";\n    $.tempest(template, {\n        is_active: true\n    });\n    // returns jQuery: [ \u003cp\u003eThis record is active.\u003c/p\u003e ]\n\nFor Loops\n---------\n\nUse this syntax:\n\n    \u003cul\u003e\n    {% for person in people %}\n       \u003cli\u003e{{ person }}\u003c/li\u003e\n    {% endfor %}\n    \u003c/ul\u003e\n\nDOM Manipulation\n----------------\n\nReplace the inner html (`$(selector).html()`) of a DOM element.\n\n    $(selector).tempest(template, context);\n\nYou can use any jquery dom manipulation with tempest:\n\n    // $(selector).append($.tempest(template, context));\n    $(selector).tempest(\"append\", template, context);\n\n    // $(selector).prepend($.tempest(template, context));\n    $(selector).tempest(\"prepend\", template, context);\n\n    // Etc... This works with *all* jQuery methods.\n    $(selector).tempest(\"before\", template, context);\n    $(selector).tempest(\"after\", template, context);\n    $(selector).tempest(\"replaceWith\", template, context);\n\nWrite your own template tags\n----------------------------\n\nAll tags are stored in $.tempest.tags. Tags have a couple things to work with:\n\nThe \"args\" property is set before render:\n\n    {% tag_type arg1 arg2 foo bar %}\n\nThe \"args\" property would be set to\n\n    [\"arg1\", \"arg2\", \"foo\", \"bar\"]\n\nin this example. The tag's render method could look them up in the context\nobject, or could do whatever it wanted to do with it.\n\nA \"subNodes\" property which is an array of all the nodes between the start tag\nand it's corresponding {% end... %} tag. NOTE: This property is only set for a\nblock if it has the \"expectsEndTag\" property set to true.\n\nEvery block tag should have a \"render\" method that takes one argument: a context\nobject. It MUST return a string.\n\nHere is an example tag that filters out profanity from the variables passed to\nit before printing them:\n\n    $.tempest.tags.filter = {\n        expectsEndTag: false,\n        render: function (context) {\n            var rendered = [];\n            for (var i = 0; i \u003c this.args.length; i++) {\n                rendered.push(\n                    $.tempest.getContextValue(this.args[i], context).replace(/shit/gi, \"#!$%\")\n                );\n            }\n            return rendered.join(\" \");\n        }\n    };\n\n    var template = \"\u003cp\u003eNo profanity here: {% filter badWord %}\u003c/p\u003e\";\n    $.tempest(template, { badWord: \"shit\" });\n    // returns jQuery: [ \u003cp\u003eNo profanity here: #!$%\u003c/p\u003e ]\n\nSince arguments are passed in as strings, if you want to get the context value\nassocciated with the argument \"object.foo.bar\", you must call\n`$.tempest.getContextValue(arg, context)`.\n\nFor another reference, see the implementation of the if tag here:\nhttp://github.com/fitzgen/tempest/blob/master/jquery.tempest.js#L69\n\nMisc.\n-----\n\nAccess an object's attributes with the dot notation:\n\n    var one-time-template = \"\u003cp\u003eMy name is \u003cem\u003e{{ me.full_name }}\u003c/em\u003e\u003c/p\u003e\";\n    $.tempest(one-time-template, {\n        \"me\": {\n            \"full_name\": \"Nick Fitzgerald\"\n        }\n\n    });\n    // returns jQuery: [ \u003cp\u003eMy name is \u003cem\u003eNick Fitzgerald\u003c/em\u003e\u003c/p\u003e ]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Ftempest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Ftempest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Ftempest/lists"}