{"id":13396376,"url":"https://github.com/soveran/mote","last_synced_at":"2025-12-30T00:13:18.974Z","repository":{"id":56884583,"uuid":"1572908","full_name":"soveran/mote","owner":"soveran","description":"Minimum Operational Template","archived":false,"fork":false,"pushed_at":"2021-04-22T16:31:53.000Z","size":66,"stargazers_count":218,"open_issues_count":2,"forks_count":19,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-18T06:23:21.218Z","etag":null,"topics":["lesscode","ruby","template"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/soveran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-05T16:40:59.000Z","updated_at":"2024-11-27T00:57:51.000Z","dependencies_parsed_at":"2022-08-20T23:40:41.051Z","dependency_job_id":null,"html_url":"https://github.com/soveran/mote","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soveran%2Fmote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soveran%2Fmote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soveran%2Fmote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soveran%2Fmote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soveran","download_url":"https://codeload.github.com/soveran/mote/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243499798,"owners_count":20300692,"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":["lesscode","ruby","template"],"created_at":"2024-07-30T18:00:48.535Z","updated_at":"2025-12-30T00:13:18.931Z","avatar_url":"https://github.com/soveran.png","language":"Ruby","funding_links":[],"categories":["Cuba Components \u0026 Related Gems","Frameworks"],"sub_categories":[],"readme":"Mote\n====\n\nMinimum Operational Template.\n\nDescription\n-----------\n\nMote is a very simple and fast template engine.\n\nUsage\n-----\n\nUsage is very similar to that of ERB:\n\n```ruby\ntemplate = Mote.parse(\"This is a template\")\ntemplate.call #=\u003e \"This is a template\"\n```\n\nSilly example, you may say, and I would agree. What follows is a short list of\nthe different use cases you may face:\n\n```\n% # This is a comment\n% if user == \"Bruno\"\n  {{user}} rhymes with Piano\n% elsif user == \"Brutus\"\n  {{user}} rhymes with Opus\n% end\n\n\u003c?\n  # Multiline code evaluation\n  lucky = [1, 3, 7, 9, 13, 15]\n  prime = [2, 3, 5, 7, 11, 13]\n?\u003e\n\n{{ lucky \u0026 prime }}\n```\n\n## Control flow\n\nLines that start with `%` are evaluated as Ruby code. Anything between\n`\u003c?` and `?\u003e`, including new lines, is also evaluated as Ruby code.\n\n## Assignment\n\nWhatever it is between `{{` and `}}` gets printed in the template.\n\n## Comments\n\nThere's nothing special about comments, it's just a `#` inside your Ruby code:\n\n```\n% # This is a comment.\n```\n\n## Block evaluation\n\nAs with control instructions, it happens naturally:\n\n```\n% 3.times do |i|\n  {{i}}\n% end\n```\n\n## Parameters\n\nThe values passed to the template are available as local variables:\n\n```ruby\nexample = Mote.parse(\"Hello {{name}}\", self, [:name])\nassert_equal \"Hello world\", example.call(name: \"world\")\nassert_equal \"Hello Bruno\", example.call(name: \"Bruno\")\n```\n\nPlease note that the keys in the parameters hash must be symbols.\n\n# Helpers\n\nThere's a helper available in the `Mote::Helpers` module, and you are\nfree to include it in your code. To do it, just type:\n\n```ruby\ninclude Mote::Helpers\n```\n\n### Using the mote helper\n\nThe `mote` helper receives a file name and a hash and returns the rendered\nversion of its content. The compiled template is cached for subsequent calls.\n\n```ruby\nassert_equal \"***\\n\", mote(\"test/basic.mote\", n: 3)\n```\n\n### Template caching\n\nWhen the `mote` helper is first called with a template name, the\nfile is read and parsed, and a proc is created and stored in the\ncurrent thread. The parameters passed are defined as local\nvariables in the template. If you want to provide more parameters\nonce the template was cached, you won't be able to access the\nvalues as local variables, but you can always access the `params`\nhash.\n\nFor example:\n\n```ruby\n# First call\nmote(\"foo.mote\", a: 1, b: 2)\n```\n\n## Command line tool\n\nMote ships with a command line tool to render mote templates. The\nresult is redirected to standard output.\n\n```\nmote FILE [param1 value1 ... paramN valueN]\n```\n\nThe extra parameters supplied will be passed to the template.\nNote that all the parameter values will be treated as strings.\n\n### Example usage\n\nIf your template is called foo.mote, you can render it with the\nfollowing command:\n\n\tmote foo.mote\n\nTo write the result to a new file, just redirect the output:\n\n\tmote foo.mote \u003e foo.html\n\nIf the template uses a local variable `bar`, you can pass a\nvalue from the command line:\n\n\tmote foo.mote bar 42\n\n## Installation\n\nYou can install it using rubygems.\n\n```\n$ gem install mote\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoveran%2Fmote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoveran%2Fmote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoveran%2Fmote/lists"}