{"id":13582017,"url":"https://github.com/Eun/yaegi-template","last_synced_at":"2025-04-06T11:32:29.393Z","repository":{"id":37884851,"uuid":"199636795","full_name":"Eun/yaegi-template","owner":"Eun","description":"Use yaegi as a template engine.","archived":true,"fork":false,"pushed_at":"2023-06-13T11:05:58.000Z","size":1048,"stargazers_count":32,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-05T21:45:37.269Z","etag":null,"topics":["go","golang","hacktoberfest","template-engine","yaegi","yaegi-template"],"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/Eun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["Eun"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":"eun","otechie":null,"custom":null}},"created_at":"2019-07-30T11:15:56.000Z","updated_at":"2024-03-13T21:51:01.000Z","dependencies_parsed_at":"2024-06-18T22:44:06.520Z","dependency_job_id":"8783153e-9d6d-410a-a08a-28474a403c0c","html_url":"https://github.com/Eun/yaegi-template","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eun%2Fyaegi-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eun%2Fyaegi-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eun%2Fyaegi-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eun%2Fyaegi-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eun","download_url":"https://codeload.github.com/Eun/yaegi-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478082,"owners_count":20945256,"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":["go","golang","hacktoberfest","template-engine","yaegi","yaegi-template"],"created_at":"2024-08-01T15:02:23.204Z","updated_at":"2025-04-06T11:32:28.749Z","avatar_url":"https://github.com/Eun.png","language":"Go","funding_links":["https://github.com/sponsors/Eun","https://issuehunt.io/r/eun"],"categories":["Go"],"sub_categories":[],"readme":"# yaegi-template [![Actions Status](https://github.com/Eun/yaegi-template/workflows/CI/badge.svg)](https://github.com/Eun/yaegi-template/actions) [![Coverage Status](https://coveralls.io/repos/github/Eun/yaegi-template/badge.svg)](https://coveralls.io/github/Eun/yaegi-template) [![PkgGoDev](https://img.shields.io/badge/pkg.go.dev-reference-blue)](https://pkg.go.dev/github.com/Eun/yaegi-template) [![GoDoc](https://godoc.org/github.com/Eun/yaegi-template?status.svg)](https://godoc.org/github.com/Eun/yaegi-template) [![go-report](https://goreportcard.com/badge/github.com/Eun/yaegi-template)](https://goreportcard.com/report/github.com/Eun/yaegi-template)\nUse [yaegi](https://github.com/traefik/yaegi) as a template engine.\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/Eun/yaegi-template\"\n)\n\nfunc main() {\n\ttemplate := yaegi_template.MustNew(yaegi_template.DefaultOptions(), yaegi_template.DefaultSymbols()...)\n\ttemplate.MustParseString(`\n\u003chtml\u003e\n\u003c$\n    import (\n        \"fmt\"\n        \"time\"\n    )\n    func GreetUser(name string) {\n        fmt.Printf(\"Hello %s, it is %s\", name, time.Now().Format(time.Kitchen))\n    }\n$\u003e\n\n\u003cp\u003e\n\u003c$\n    if context.LoggedIn {\n        GreetUser(context.UserName)\n    }\n$\u003e\n\u003c/p\u003e\n\u003c/html\u003e\n`)\n\n    type Context struct {\n        LoggedIn bool\n        UserName string\n    }\n\n    template.MustExec(os.Stdout, \u0026Context{\n        LoggedIn: true,\n        UserName: \"Joe Doe\",\n    })\n}\n```\n\n## Example #2\nYou can use `\u003c$-` to strip white spaces before the code block and\n`-$\u003e` to strip white spaces after the code block.  \nAlso omitting the print statement for simple evaluations is possible.\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/Eun/yaegi-template\"\n\t\"github.com/traefik/yaegi/interp\"\n\t\"github.com/traefik/yaegi/stdlib\"\n)\n\nfunc main() {\n\ttemplate := yaegi_template.MustNew(interp.Options{}, stdlib.Symbols)\n\ttemplate.MustParseString(`\n\u003chtml\u003e\n\u003cp\u003e\n\u003c$-\n    context.UserName\n-$\u003e\n\u003c/html\u003e\n`)\n\n\ttype Context struct {\n\t\tLoggedIn bool\n\t\tUserName string\n\t}\n\n\ttemplate.MustExec(os.Stdout, \u0026Context{\n\t\tLoggedIn: true,\n\t\tUserName: \"Joe Doe\",\n\t})\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEun%2Fyaegi-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEun%2Fyaegi-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEun%2Fyaegi-template/lists"}