{"id":24418700,"url":"https://github.com/thecodedrift/tig","last_synced_at":"2025-03-13T13:16:23.048Z","repository":{"id":139336043,"uuid":"2329654","full_name":"thecodedrift/Tig","owner":"thecodedrift","description":"jQuery Template Awesomepower","archived":false,"fork":false,"pushed_at":"2012-09-14T23:27:45.000Z","size":120,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T03:44:55.314Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodedrift.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-09-05T17:52:36.000Z","updated_at":"2013-09-30T09:26:24.000Z","dependencies_parsed_at":"2023-03-24T05:49:26.913Z","dependency_job_id":null,"html_url":"https://github.com/thecodedrift/Tig","commit_stats":null,"previous_names":["thecodedrift/tig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodedrift%2FTig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodedrift%2FTig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodedrift%2FTig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodedrift%2FTig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodedrift","download_url":"https://codeload.github.com/thecodedrift/Tig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243410459,"owners_count":20286403,"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":"2025-01-20T09:11:29.372Z","updated_at":"2025-03-13T13:16:23.028Z","avatar_url":"https://github.com/thecodedrift.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tig: A template in your HTML, sans \u003c, {, {{, etc\n===\nIt's much easier to build a page in HTML first, and then fuse dynamic data to it. That's the philosophy behind Tig- build your page, annotate it, and then add the data.\n\nQuick Start\n---\n```\n$(document).ready(function() {\n  $(document.body).tig({\n    user: {\n      name: \"John Doe\",\n      looped: [\n        { foo: \"one\" },\n        { foo: \"two\" },\n        { foo: \"three\" }\n      ]\n    }\n  });\n});\n```\n\nAnd your markup...\n\n```\n\u003cp data-tig-content=\"#{user/name} or ''\"\u003eFred Farkas\u003c/p\u003e\n\u003cp data-tig-content=\"#{user/idea} or 'none'\"\u003eBrilliant\u003c/p\u003e\n\n\u003ca href=\"#\" class=\"one\" data-tig-attribute=\"href = 'http://www.google.com', class += ' two'\"\u003eattr changes\u003c/a\u003e\n\n\u003cdiv data-tig-condition=\"#{user/tested} or (#{user/otherTested} and #{user/otherTestedB})\"\u003etested\u003c/div\u003e\n\u003cdiv data-tig-omit=\"true\"\u003eI get dropped\u003cp\u003eand me\u003c/p\u003e\u003c/div\u003e\n\u003cul\u003e\n  \u003cli data-tig-repeat=\"#{user/looped} as item\"\u003e\u003cp\u003eTest\u003c/p\u003e\u003cp data-tig-content=\"#{item/foo}\"\u003erepl\u003c/p\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv data-tig-define=\"localTest = 'is local!'\"\u003e\n  \u003cdiv\u003e\n    \u003cdiv data-tig-content=\"#{localTest}\"\u003enot local\u003c/div\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\nCompatibility\n---\nIt's built as a jQuery extension right now, only because I'm not convinced it's worth adding the attribute selection layer in natively plus DOM Manipulation. If you're using nodejs, then jsdom is your friend and you won't have to do much else.\n\nLicense\n---\nBSD\n\nManual\n===\nEverything in Tig is set up using data-* attributes. The Tig namespace is reserved for this purpose. Your document will be parsed then in the following order:\n\n* Define\n* Condition\n* Repeat\n* Content\n* Replace\n* Attributes\n* Omit\n* Block\n\nExpressions\n---\nThroughout the document, you will often see reference to the word(s) [expression]. An expression is a statement that can be evaluated into a runnable path. The following are valid expressions:\n\n* #{foo/bar/baz}: In a data object, search and locate the object at `foo.bar.baz`\n* \"and\", \"or\": map to `\u0026\u0026` and `||` respectively\n* \"gt\", \"lt\", \"gte\", \"lte\": map to `\u003e`, `\u003c`, `\u003e=`, `\u003c=` respectively\n* \"eq\", \"ex\": map to `==` and `===` respectively\n* \"structure \": when an expression begins with this, it's literal value will be used (unescaped)\n\nUsing the above syntax, the following kinds of expressions are possible\n\n* #{foo/bar} or null: `foo.bar || null`\n* #{repeat/index} eq 3: `repeat.index == 3`\n\ndata-tig-define=\"`[local|global] [var] = [expression]`\"\n---\nDefine either a [local] or [global] variable named [var], and set it to the provided [expression]. Local variables will last until the tag's closure, while global variables will persist through the parse operation.\n\nIf neither \"local\" or \"global\" is defined, it is assumed to be local.\n\ndata-tig-condition=\"`[expression]`\"\n---\nEvaluates [expression] and if true, the html will be rendered. If it evaluates to false, the html will be removed from the document.\n\ndata-tig-repeat=\"`[expression] as [var]`\"\n---\nEvaluates [expression] and repeats the given node N times, where N is the number of items in the collection. For any given item, a local variable will be created repeat/[var] which contains the item in the iteration.\n\nDuring the iteration, the following additional variables are available within the \"repeat/`[var]`\" namespace\n\n* #{repeat/[var]/index}: the value of the current iteration (array based)\n* #{repeat/[var]/number}: the number of the iteration (human readable)\n* #{repeat/[var]/even}: true if this is an even value\n* #{repeat/[var]/odd}: true if this is an odd value\n* #{repeat/[var]/start}: the starting index for the iteration (array based)\n* #{repeat/[var]/end}: the last value in the iteration (array based)\n* #{repeat/[var]/length}: the total number of items in the iteration\n\ndata-tig-content=\"`[expression]`\"\n---\nReplace the contents of the node with the results of [expression]\n\ndata-tig-replace=\"`[expression]`\"\n---\nReplace the current node with the results of [expression]\n\ndata-tig-attributes=\"`[attr] [=|+=] [expression]`\"\n---\nSet a given attribute [=] or add to an existing attribute [+=] the value of [expression]. This is useful for supplementing with things such as a class or setting an href for a link.\n\ndata-tig-omit=\"`[expression]`\"\n---\nIf the expression evaluates to true, then the block will be removed. This is a simpler form of `data-tig-condition`.\n\ndata-tig-block=\"\"\n---\nThis item has no expression. If encountered, the node will be treated as a \"null\" node, and will remove itself from the document. All its children will be promoted one level.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodedrift%2Ftig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodedrift%2Ftig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodedrift%2Ftig/lists"}