{"id":13835641,"url":"https://github.com/k0kubun/hamlit","last_synced_at":"2025-05-14T06:12:26.939Z","repository":{"id":29580153,"uuid":"33119874","full_name":"k0kubun/hamlit","owner":"k0kubun","description":"High Performance Haml Implementation","archived":false,"fork":false,"pushed_at":"2023-08-02T18:07:16.000Z","size":2011,"stargazers_count":981,"open_issues_count":0,"forks_count":59,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-07T01:03:06.190Z","etag":null,"topics":["haml","ruby","template-engine"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/hamlit","language":"Ruby","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/k0kubun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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},"funding":{"github":"k0kubun"}},"created_at":"2015-03-30T11:43:34.000Z","updated_at":"2025-03-27T21:39:59.000Z","dependencies_parsed_at":"2024-10-21T12:49:43.354Z","dependency_job_id":null,"html_url":"https://github.com/k0kubun/hamlit","commit_stats":{"total_commits":1247,"total_committers":36,"mean_commits":"34.638888888888886","dds":0.1932638331996792,"last_synced_commit":"cf7908a0b3621e8a4fef26d1de43ae8ea875f23a"},"previous_names":[],"tags_count":126,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k0kubun%2Fhamlit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k0kubun%2Fhamlit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k0kubun%2Fhamlit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k0kubun%2Fhamlit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k0kubun","download_url":"https://codeload.github.com/k0kubun/hamlit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281414,"owners_count":21077423,"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":["haml","ruby","template-engine"],"created_at":"2024-08-04T14:01:07.246Z","updated_at":"2025-04-10T23:23:47.163Z","avatar_url":"https://github.com/k0kubun.png","language":"Ruby","funding_links":["https://github.com/sponsors/k0kubun"],"categories":["Ruby"],"sub_categories":[],"readme":"# Hamlit\n\n[![Gem Version](https://badge.fury.io/rb/hamlit.svg)](http://badge.fury.io/rb/hamlit)\n[![test](https://github.com/k0kubun/hamlit/workflows/test/badge.svg)](https://github.com/k0kubun/hamlit/actions?query=workflow%3Atest)\n\nHamlit is a high performance [Haml](https://github.com/haml/haml) implementation.\n\n## Project status\n\n**Hamlit's implementation was copied to Haml 6.**\nFrom Haml 6, you don't need to switch to Hamlit.\n\nBoth Haml 6 and Hamlit are still maintained by [k0kubun](https://github.com/k0kubun).\nWhile you don't need to immediately deprecate Hamlit, Haml 6 has more maintainers\nand you'd better start a new project with Haml rather than Hamlit,\ngiven no performance difference between them.\n\n## Introduction\n\n### What is Hamlit?\nHamlit is another implementation of [Haml](https://github.com/haml/haml).\nWith some [Hamlit's characteristics](REFERENCE.md#hamlits-characteristics) for performance,\nHamlit is **1.94x times faster** than the original Haml 5 in [this benchmark](benchmark/run-benchmarks.rb),\nwhich is an HTML-escaped version of [slim-template/slim's one](https://github.com/slim-template/slim/blob/4.1.0/benchmarks/run-benchmarks.rb) for fairness.\n\n\u003cimg src=\"https://raw.githubusercontent.com/k0kubun/hamlit/afcc2b36c4861c2f764baa09afd9530ca25eeafa/benchmark/graph/graph.png\" width=\"600x\" alt=\"Hamlit Benchmark\" /\u003e\n\n```\n      hamlit v2.13.0:   247404.4 i/s\n        erubi v1.9.0:   244356.4 i/s - 1.01x slower\n         slim v4.1.0:   238254.3 i/s - 1.04x slower\n         faml v0.8.1:   197293.2 i/s - 1.25x slower\n         haml v5.2.0:   127834.4 i/s - 1.94x slower\n```\n\n### Why is Hamlit fast?\n\n#### Less string concatenation by design\nAs written in [Hamlit's characteristics](REFERENCE.md#hamlits-characteristics),\nHamlit drops some not-so-important features which require works on runtime.\nWith the optimized language design, we can reduce the string concatenation\nto build attributes.\n\n#### Static analyzer\nHamlit analyzes Ruby expressions with Ripper and render it on compilation if the expression\nis static. And Hamlit can also compile string literal with string interpolation to reduce\nstring allocation and concatenation on runtime.\n\n#### C extension to build attributes\nWhile Hamlit has static analyzer and static attributes are rendered on compilation,\ndynamic attributes must be rendered on runtime. So Hamlit optimizes rendering on runtime\nwith C extension.\n\n## Usage\n\nSee [REFERENCE.md](REFERENCE.md) for details.\n\n### Rails\n\nAdd this line to your application's Gemfile or just replace `gem \"haml\"` with `gem \"hamlit\"`.\nIt enables rendering by Hamlit for \\*.haml automatically.\n\n```rb\ngem 'hamlit'\n```\n\nIf you want to use view generator, consider using [hamlit-rails](https://github.com/mfung/hamlit-rails).\n\n### Sinatra\n\nReplace `gem \"haml\"` with `gem \"hamlit\"` in Gemfile, and require \"hamlit\".\n\nWhile Haml disables `escape_html` option by default, Hamlit enables it for security.\nIf you want to disable it, please write:\n\n```rb\nset :haml, { escape_html: false }\n```\n\n\n## Command line interface\n\nYou can see compiled code or rendering result with \"hamlit\" command.\n\n```bash\n$ gem install hamlit\n$ hamlit --help\nCommands:\n  hamlit compile HAML    # Show compile result\n  hamlit help [COMMAND]  # Describe available commands or one specific command\n  hamlit parse HAML      # Show parse result\n  hamlit render HAML     # Render haml template\n  hamlit temple HAML     # Show temple intermediate expression\n\n$ cat in.haml\n- user_id = 123\n%a{ href: \"/users/#{user_id}\" }\n\n# Show compiled code\n$ hamlit compile in.haml\n_buf = [];  user_id = 123;\n; _buf \u003c\u003c (\"\u003ca href='/users/\".freeze); _buf \u003c\u003c (::Hamlit::Utils.escape_html((user_id))); _buf \u003c\u003c (\"'\u003e\u003c/a\u003e\\n\".freeze); _buf = _buf.join\n\n# Render html\n$ hamlit render in.haml\n\u003ca href='/users/123'\u003e\u003c/a\u003e\n```\n\n## Contributing\n\n### Reporting an issue\n\nPlease report an issue with following information:\n\n- Full error backtrace\n- Haml template\n- Ruby version\n- Hamlit version\n- Rails/Sinatra version\n\n### Coding styles\n\nPlease follow the existing coding styles and do not send patches including cosmetic changes.\n\n## License\n\nCopyright (c) 2015 Takashi Kokubun\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk0kubun%2Fhamlit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk0kubun%2Fhamlit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk0kubun%2Fhamlit/lists"}