{"id":23946171,"url":"https://github.com/ermos/strlang","last_synced_at":"2025-02-24T07:16:11.949Z","repository":{"id":99157195,"uuid":"608601877","full_name":"ermos/strlang","owner":"ermos","description":"🏗️ fluent string builder interface for generate code easily with go","archived":false,"fork":false,"pushed_at":"2023-03-10T10:36:55.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-06T08:37:50.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/ermos.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-02T11:05:51.000Z","updated_at":"2023-03-02T23:49:31.000Z","dependencies_parsed_at":"2023-05-15T12:45:34.635Z","dependency_job_id":null,"html_url":"https://github.com/ermos/strlang","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"83425c20a60b759e2462570387cd05ba4fe10caa"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fstrlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fstrlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fstrlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermos%2Fstrlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ermos","download_url":"https://codeload.github.com/ermos/strlang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240434302,"owners_count":19800550,"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-06T08:28:48.454Z","updated_at":"2025-02-24T07:16:11.929Z","avatar_url":"https://github.com/ermos.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strlang\n\u003e 🏗️ fluent string builder interface for generate code easily with go\n\n`strlang` is a Go package for building string-based programming languages.\nIt provides a simple way to generate strings of code that can be used\nin different programming languages.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/ermos/strlang.svg)](https://pkg.go.dev/github.com/ermos/strlang)\n[![Latest tag](https://img.shields.io/github/v/tag/ermos/strlang?label=latest)](https://github.com/ermos/strlang/tags)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ermos/strlang)](https://goreportcard.com/report/github.com/ermos/strlang)\n[![Maintainability](https://api.codeclimate.com/v1/badges/4d4e0548b083618eba7d/maintainability)](https://codeclimate.com/github/ermos/strlang/maintainability)\n[![codecov](https://codecov.io/github/ermos/strlang/branch/main/graph/badge.svg?token=52FCLZVA0B)](https://codecov.io/github/ermos/strlang)\n## 🛠️ Installation\n\nTo use `strlang` in your Go project, you need to have Go installed on your system.\nOnce you have Go installed, you can use the following command to install the package:\n\n```go\ngo get -u github.com/ermos/strlang\n```\n\n## 📚 Examples\nHere are some examples of how to use `strlang` to generate code in different programming languages.\nIf your wanted programming language isn't implemented, you can use directly the default builder.\n\n### Javascript\nHere is an example of how to use Strlang to generate JavaScript code:\n\n#### Code\n```go\npackage main\n\nimport (\n\t\"github.com/ermos/strlang\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tjs := strlang.NewJavascript()\n\n\tjs.Object(\"const\", \"person\", func() {\n\t\tjs.WriteStringln(`name: \"John\",`)\n\t\tjs.WriteStringln(`age: 31,`)\n\t\tjs.WriteStringln(`city: \"New York\"`)\n\t})\n\n\tjs.If(\"person.age \u003e 18\", func() {\n\t\tjs.WriteStringln(`console.log(\"John is an adult\");`)\n\t})\n\tjs.Else(func() {\n\t\tjs.WriteStringln(\"console.log('John is not an adult');\")\n\t})\n\t\n\tfmt.Println(js.String())\n}\n```\n\n#### Output\n```javascript\nconst person = {\n    name: \"John\",\n    age: 31,\n    city: \"New York\"\n};\n\nif (person.age \u003e 18) {\n    console.log(\"John is an adult\");\n} else {\n    console.log(\"John is not an adult\");\n}\n```\n\n### PHP\nHere is an example of how to use Strlang to generate PHP code:\n\n#### Code\n```go\npackage main\n\nimport (\n\t\"github.com/ermos/strlang\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tphp := strlang.NewPHP(\"App/Models\")\n\n\tphp.Class(\"Person\", func() {\n\t\tphp.ClassFunc(\"public\", \"__construct\", \"$name, $age\", \"\", func() {\n\t\t\tphp.WriteStringln(`$this-\u003ename = $name;`)\n\t\t\tphp.WriteStringln(`$this-\u003eage = $age;`)\n\t\t})\n\t})\n\n\tfmt.Println(php.String())\n}\n```\n\n#### Output\n```php\n\u003c?php\n\nnamespace MyNamespace;\n\nclass Person {\n    public function __construct($name, $age) {\n        $this-\u003ename = $name;\n        $this-\u003eage = $age;\n    }\n}\n```\n\n## 💡 Usage\n\n`strlang` provides a set of builders for each programming language.\nEach builder has methods that allow you to build code constructs in that language.\nYou can use the `New` method of your wanted language (example for javascript: `NewJavascript()`)\nfunctions to create instances of the corresponding builders.\nOnce you have a builder instance, you can use its methods to build code constructs.\n\nFor more information about the available methods and how to use them, please refer to the package documentation.\n\n## 🤝 Contributing\n\nContributions to `strlang` are always welcome!\nIf you find a bug or have a feature request, please open an issue on GitHub.\nIf you want to contribute code, please fork the repository and submit a pull request.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermos%2Fstrlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fermos%2Fstrlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermos%2Fstrlang/lists"}