{"id":16068028,"url":"https://github.com/ged/inversion","last_synced_at":"2025-03-18T05:31:01.522Z","repository":{"id":65988004,"uuid":"1605926","full_name":"ged/inversion","owner":"ged","description":"Inversion is a templating system for Ruby. It uses the \"Inversion of Control\" principle to decouple the contents and structure of templates from the code that uses them, making it easier to separate concerns, keep your tests simple, and avoid polluting scopes with ephemeral data. (github mirror)","archived":false,"fork":false,"pushed_at":"2022-12-22T01:18:29.000Z","size":837,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T07:32:33.354Z","etag":null,"topics":["inversion-of-control","ruby","template"],"latest_commit_sha":null,"homepage":"https://hg.sr.ht/~ged/Inversion","language":"Ruby","has_issues":false,"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/ged.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"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-04-12T19:51:30.000Z","updated_at":"2022-12-22T00:54:25.000Z","dependencies_parsed_at":"2023-04-14T04:30:51.728Z","dependency_job_id":null,"html_url":"https://github.com/ged/inversion","commit_stats":{"total_commits":364,"total_committers":5,"mean_commits":72.8,"dds":"0.14010989010989006","last_synced_commit":"32280fab2ffe3e980b83830e8a82298db4497d7c"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Finversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Finversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Finversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ged%2Finversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ged","download_url":"https://codeload.github.com/ged/inversion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243903155,"owners_count":20366431,"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":["inversion-of-control","ruby","template"],"created_at":"2024-10-09T06:07:59.752Z","updated_at":"2025-03-18T05:31:01.517Z","avatar_url":"https://github.com/ged.png","language":"Ruby","readme":"# inversion\n\nhome\n: https://hg.sr.ht/~ged/Inversion\n\ncode\n: https://hg.sr.ht/~ged/Inversion/browse\n\ngithub\n: https://github.com/ged/inversion\n\ndocs\n: http://deveiate.org/code/inversion\n\n\n## Description\n\nInversion is a templating system for Ruby. It uses the \"Inversion of Control\"\nprinciple to decouple the contents and structure of templates from the code\nthat uses them, making it easier to separate concerns, keep your tests simple,\nand avoid polluting scopes with ephemeral data.\n\n\n### Details\n\nInversion, like most other templating systems, works by giving you a way of\ndefining the static parts of your output, and then letting you combine that at\na later point with the dynamic parts:\n\nCreate the template and use it to render an exciting message:\n\n    tmpl = Inversion::Template.new( \"Hello, \u003c?attr name ?\u003e!\" )\n    tmpl.name = \"World\"\n    puts tmpl.render\n\nThe `\u003c?attr name ?\u003e` tag defines the _name_ accessor on the template\nobject, the value of which is substituted for any occurrences of `name` in the\ntemplate:\n\n    Hello, World!\n\nThis by itself isn't fantastically useful, but it does illustrate one of the\nways in which Inversion is different: the program and the template share data\nthrough an API, instead of through a complex data structure, which establishes\na clear delineation between what responsibility is the program's and which is\nthe template's. The program doesn't have to know how the view uses the data\nit's given, and tests of the controller can substitute a Mock Object for the\ntemplate to test the interaction between the two instead of having to match\npatterns in the eventual output like an integration test.\n\nYou can also interact with the values set in the template:\n\n    Name: \u003c?attr employee.full_name ?\u003e\n\nThis will call the #full_name method on whatever is set as the `employee`\nattribute when rendered, and the result will take the place of the tag.\n\nInversion also comes with [a collection of other tags](rdoc-ref:Tags) that\nprovide flow control, exception-handling, etc.\n\nHere's a slightly more complex example: Say we have a layout template that\ncontains all the boilerplate, navigation, etc. for the site, and then an\n`\u003c?attr body ?\u003e` somewhere in the content area for the content specific to\neach view:\n\n    layout = Inversion::Template.load( 'templates/layout.tmpl' )\n\nThen there's a view template that displays a bulleted list of article titles:\n \n    \u003c!-- articlelist.tmpl --\u003e\n    \u003csection id=\"articles\"\u003e\n      \u003cul\u003e\n      \u003c?for article in articles ?\u003e\n        \u003cli\u003e\u003c?call article.title ?\u003e\u003c/li\u003e\n      \u003c?end for ?\u003e\n      \u003c/ul\u003e\n    \u003c/section\u003e\n\nLoading this template results in a Ruby object whose API contains one method:\n`#articles`. To render the view, we just call that accessor with instances of\nan `Article` domain class we defined elsewhere, and then drop the `alist`\ntemplate into the layout and render them:\n\n    alist = Inversion::Template.load( 'templates/alist.tmpl' )\n    alist.articles = Articles.latest( 10 )\n    \n    layout.body = alist\n    puts layout.render\n\nThe `for` tag in the alist will iterate over the enumerable Articles and\ngenerate an `\u003cli\u003e` for each one. The resulting template object will be set as\nthe body of the layout template, and stringified when the enclosing template\nis rendered. Templates can be nested this way as deeply as you like.\n\nFor detailed tag documentation and examples, start with the Inversion::Template\nclass in the API documentation.\n\n\n## References\n\n* Inversion of Control - https://en.wikipedia.org/wiki/Inversion_of_control\n* Passive View - https://martinfowler.com/eaaDev/PassiveScreen.html\n* Supervising Controller - https://martinfowler.com/eaaDev/SupervisingPresenter.html\n\n\n## Installation\n\n    gem install inversion\n\n\n## Contributing\n\nYou can check out the current development source\n[with Mercurial](https://hg.sr.ht/~ged/Inversion), or if you prefer Git, via the\nproject's [Github mirror](https://github.com/ged/Inversion).\n\nYou can submit bug reports, suggestions, and read more about future plans at\n[the project page](https://hg.sr.ht/~ged/Inversion).\n\nAfter checking out the source, run:\n\n    $ gem install -Ng\n    $ rake setup\n\nThis task will install any missing dependencies and do any necessary developer\nsetup.\n\n\n## Authors\n\n* Michael Granger \u003cged@faeriemud.org\u003e\n* Mahlon E. Smith \u003cmahlon@martini.nu\u003e\n\n\n## License\n\nCopyright © 2011-2022, Michael Granger and Mahlon E. Smith\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice,\n  this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\n* Neither the name of the author/s, nor the names of the project's\n  contributors may be used to endorse or promote products derived from this\n  software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fged%2Finversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fged%2Finversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fged%2Finversion/lists"}