{"id":22724258,"url":"https://github.com/niceue/tpl.js","last_synced_at":"2025-04-13T17:52:06.277Z","repository":{"id":145772790,"uuid":"10541387","full_name":"niceue/tpl.js","owner":"niceue","description":"Lightweight javascript template engine","archived":false,"fork":false,"pushed_at":"2014-10-23T15:19:08.000Z","size":333,"stargazers_count":39,"open_issues_count":0,"forks_count":22,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T08:48:20.578Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://niceue.github.io/tpl.js/","language":"JavaScript","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/niceue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-07T03:02:12.000Z","updated_at":"2023-07-10T05:00:53.000Z","dependencies_parsed_at":"2023-03-23T22:00:15.984Z","dependency_job_id":null,"html_url":"https://github.com/niceue/tpl.js","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceue%2Ftpl.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceue%2Ftpl.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceue%2Ftpl.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceue%2Ftpl.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niceue","download_url":"https://codeload.github.com/niceue/tpl.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758446,"owners_count":21156957,"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":"2024-12-10T14:15:31.365Z","updated_at":"2025-04-13T17:52:06.247Z","avatar_url":"https://github.com/niceue.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## tpl.js\nLightweight javascript template engine. Adaptation AMD, CMD and global environment\n\n[Speed Test](http://jsperf.com/dom-vs-innerhtml-based-templating/780)\n\n\n## Usage\n\n1. Include `tpl.js`:\n``` html\n    \u003cscript type=\"text/javascript\" src=\"path/to/tpl.js\"\u003e\u003c/script\u003e\n```\nOr in sea.js, you can include by: `var tpl = require('path/to/tpl');`\n\n\n2. Template in your html:\n``` html\n    \u003cscript type=\"text/template\" id=\"demo\"\u003e\n        \u003cp\u003eHi, I'm \u003c#=author#\u003e\u003c/p\u003e\n        \u003cp\u003eI can write:\n        \u003c# for(var i=0; i\u003clanguages.length; i++) { #\u003e\n        \u003c#=(i===0?\"\":\",\")+languages[i]#\u003e\n        \u003c#}#\u003e\n        \u003c/p\u003e\n    \u003c/script\u003e\n```\nOr use internal method `echo()`:\n``` html\n    \u003cscript type=\"text/template\" id=\"demo\"\u003e\n        \u003cp\u003eHi, I'm \u003c#=author#\u003e\u003c/p\u003e\n        \u003cp\u003eI can write:\n        \u003c# \n        for(var i=0; i\u003clanguages.length; i++) { \n            echo( (i===0?\"\":\", \") + languages[i] );\n        }#\u003e\n        \u003c/p\u003e\n    \u003c/script\u003e\n```\n    \n\n3. Execution rendering:\n``` js\n    console.log( tpl('#demo', {author: \"Jony\", languages: [\"javascript\", \"php\", \"shell\"]}) );\n```\n\n4. Result is:\n``` html\n\u003cp\u003eHi, I'm Jony\u003c/p\u003e\n\u003cp\u003eI can write: javascript, php, shell\u003c/p\u003e\n```\n\n## API\n##### Include another template: `\u003c# include(\"#tpl_id\") #\u003e`\n##### Get HTML: `tpl(template, data)`\n##### Get HTML: `tpl(template)(data)`\n##### Precompiled: `tpl(template)`\n`template` can be a html template string or '#' plus an id, This will return a rendered html string.\n    \n\n## Browser Support\n\n  * IE6+\n  * Chrome\n  * Safari 4+\n  * Firefox 3.5+\n  * Opera\n\n## Bugs / Contributions\n- [Report a bug](https://github.com/niceue/tpl.js/issues)\n- To contribute or send an idea, github message me or fork the project\n\n## Build\ntpl.js use [UglifyJS2](https://github.com/mishoo/UglifyJS) \nyou should have installed [nodejs](nodejs.org) and run `npm install uglify-js -g`.\n\nOn Windows, you can run `build.bat` from root directory and it will package `tpl.debug.js` into `tpl.js`.\n\n  \n## License\n\ntpl.js is available under the terms of the [MIT License](https://github.com/niceue/tpl.js/blob/master/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniceue%2Ftpl.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniceue%2Ftpl.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniceue%2Ftpl.js/lists"}