{"id":13483874,"url":"https://github.com/jeromegn/slang","last_synced_at":"2025-07-31T02:02:04.363Z","repository":{"id":51266331,"uuid":"51259427","full_name":"jeromegn/slang","owner":"jeromegn","description":"Slim-inspired templating language for Crystal","archived":false,"fork":false,"pushed_at":"2022-12-20T19:56:49.000Z","size":100,"stargazers_count":238,"open_issues_count":15,"forks_count":30,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T06:09:20.743Z","etag":null,"topics":["crystal","kilt","slang","template-language"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","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/jeromegn.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-02-07T18:28:59.000Z","updated_at":"2025-03-24T09:44:56.000Z","dependencies_parsed_at":"2022-08-12T23:00:41.363Z","dependency_job_id":null,"html_url":"https://github.com/jeromegn/slang","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegn%2Fslang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegn%2Fslang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegn%2Fslang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegn%2Fslang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeromegn","download_url":"https://codeload.github.com/jeromegn/slang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008629,"owners_count":21032556,"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":["crystal","kilt","slang","template-language"],"created_at":"2024-07-31T17:01:16.326Z","updated_at":"2025-04-09T09:06:02.548Z","avatar_url":"https://github.com/jeromegn.png","language":"Crystal","funding_links":[],"categories":["Template Engine"],"sub_categories":[],"readme":"# Slang [![Build Status](https://travis-ci.org/jeromegn/slang.svg?branch=master)](https://travis-ci.org/jeromegn/slang)\n\nLightweight, terse, templating language for Crystal.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  slang:\n    github: jeromegn/slang\n```\n\n## Usage\n\n### Preferred: use Kilt\n\n[Kilt](https://github.com/jeromegn/kilt) is included as a dependency for this project. It should help integrating non-ECR template engines.\n\nAdd this to your application's `shard.yml`:\n```yaml\ndependencies:\n  kilt:\n    github: jeromegn/kilt\n```\n\n```\nrequire \"kilt/slang\"\n\nKilt.render(\"path/to/file.slang\") #=\u003e \u003ccompiled template\u003e\n```\n\nExample with [Kemal](http://kemalcr.com) (includes Kilt):\n\n```crystal\nrequire \"kilt/slang\"\n\nget \"/\" do\n  Kilt.render \"path/to/file.slang\"\nend\n```\n\n### Without Kilt\n\n```crystal\nString.build do |str|\n  Slang.embed(\"path/to/file.slang\", \"str\")\nend\n```\n\n## Syntax\n\n```slim\ndoctype html\nhtml\n  head\n    meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\"\n    title This is a title\n    css:\n      h1 {color: red;}\n      p {color: green;}\n    style h2 {color: blue;}\n  body\n    /! Visible multi-line comment\n      span this is wrapped in a comment\n    /[if IE]\n      p Dat browser is old.\n    / Invisible multi-line comment\n      span this is wrapped in a comment\n    h1 This is a slang file\n    h2 This is blue\n    input type=\"checkbox\" checked=false\n    input type=\"checkbox\" checked=true\n    input type=\"checkbox\" checked=\"checked\"\n    span#some-id.classname\n      #hello.world.world2\n        - some_var = \"hello world haha\"\n        span\n          span data-some-var=some_var two-attr=\"fun\" and a #{p(\"hello\")}\n          span\n            span.deep_nested\n              p\n                | text inside of \u003cp\u003e\n              = Process.pid\n              | text node\n              ' other text node\n        span.alongside pid=Process.pid\n          custom-tag#with-id pid=\"#{Process.pid}\"\n            - [\"ah\", \"oh\"].each do |s|\n              span = s\n    / This is an invisible comment\n    - if true == true\n      #amazing-div some-attr=\"hello\"\n    - else\n      #not-so-amazing-div some-attr=\"goodbye\"\n    /! This is a visible comment\n    script var num1 = 8*4;\n\n    javascript:\n      var num2 = 8*3;\n      alert(\"8 * 3 + 8 * 4 = \" + (num1 + num2));\n```\n\nGiven the context:\n\n```crystal\nsome_var = \"hello\"\nstrings = [\"ah\", \"oh\"]\n```\n\nCompiles to HTML:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\"\u003e\n    \u003ctitle\u003eThis is a title\u003c/title\u003e\n    \u003cstyle\u003e\n      h1 {color: red;}\n      p {color: green;}\n    \u003c/style\u003e\n    \u003cstyle\u003eh2 {color: blue;}\u003c/style\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003c!--Visible multi-line comment\n      \u003cspan\u003ethis is wrapped in a comment\u003c/span\u003e\n    --\u003e\n    \u003c!--[if IE]\u003e\n      \u003cp\u003eDat browser is old.\u003c/p\u003e\n    \u003c![endif]--\u003e\n    \u003ch1\u003eThis is a slang file\u003c/h1\u003e\n    \u003ch2\u003eThis is blue\u003c/h2\u003e\n    \u003cinput type=\"checkbox\"/\u003e\n    \u003cinput type=\"checkbox\" checked/\u003e\n    \u003cinput type=\"checkbox\" checked=\"checked\"/\u003e\n    \u003cspan id=\"some-id\" class=\"classname\"\u003e\n      \u003cdiv id=\"hello\" class=\"world world2\"\u003e\n        \u003cspan\u003e\n          \u003cspan data-some-var=\"hello world haha\" two-attr=\"fun\"\u003eand a hello\u003c/span\u003e\n          \u003cspan\u003e\n            \u003cspan class=\"deep_nested\"\u003e\n              \u003cp\u003e\n                text inside of \u0026lt;p\u0026gt;\n              \u003c/p\u003e\n              #{Process.pid}\n              text node\n              other text node\n            \u003c/span\u003e\n          \u003c/span\u003e\n        \u003c/span\u003e\n        \u003cspan class=\"alongside\" pid=\"#{Process.pid}\"\u003e\n          \u003ccustom-tag id=\"with-id\" pid=\"#{Process.pid}\"\u003e\n            \u003cspan\u003eah\u003c/span\u003e\n            \u003cspan\u003eoh\u003c/span\u003e\n          \u003c/custom-tag\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/span\u003e\n    \u003cdiv id=\"amazing-div\" some-attr=\"hello\"\u003e\u003c/div\u003e\n    \u003c!--This is a visible comment--\u003e\n    \u003cscript\u003evar num1 = 8*4;\u003c/script\u003e\n    \u003cscript\u003e\n      var num2 = 8*3;\n      alert(\"8 * 3 + 8 * 4 = \" + (num1 + num2));\n    \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Difference between single and double equals in Slang\n\n* `=` inserts HTML with escaped characters\n* `==` inserts HTML without escaping. It is needed when you have already rendered HTML and you need to insert it to your layout directly.\n\n## TODO\n\n- [x] Fix known limitations\n- [ ] More tests\n- [ ] Website\n- [ ] Documentation\n\n## Contributing\n\n1. Fork it ( https://github.com/jeromegn/slang/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [jeromegn](https://github.com/jeromegn) Jerome Gravel-Niquet - creator, maintainer\n- [kRaw1er](https://github.com/kRaw1er) Dmitry Neveshkin\n- [elorest](https://github.com/elorest) Isaac Sloan\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromegn%2Fslang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeromegn%2Fslang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromegn%2Fslang/lists"}