{"id":13826836,"url":"https://github.com/umakantp/jsmart","last_synced_at":"2025-04-09T05:07:08.583Z","repository":{"id":12421491,"uuid":"15076125","full_name":"umakantp/jsmart","owner":"umakantp","description":"jSmart is Smarty Javascript Template Engine, port of the PHP Smarty Template Engine","archived":false,"fork":false,"pushed_at":"2024-10-10T01:42:22.000Z","size":2100,"stargazers_count":134,"open_issues_count":10,"forks_count":35,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-02T03:16:27.646Z","etag":null,"topics":["javascript","javascript-template-engine","jsmart","smarty","smarty-template-engine","template-engine"],"latest_commit_sha":null,"homepage":"","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/umakantp.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":"2013-12-10T12:08:53.000Z","updated_at":"2024-03-03T08:09:05.000Z","dependencies_parsed_at":"2024-01-18T04:09:07.760Z","dependency_job_id":"49e2cb1e-6b67-45b7-a0c8-c65161bd05c1","html_url":"https://github.com/umakantp/jsmart","commit_stats":{"total_commits":341,"total_committers":11,"mean_commits":31.0,"dds":0.6099706744868035,"last_synced_commit":"3ec0ce265749a3cc14fd6e72d02b00ff3c689243"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umakantp%2Fjsmart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umakantp%2Fjsmart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umakantp%2Fjsmart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umakantp%2Fjsmart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umakantp","download_url":"https://codeload.github.com/umakantp/jsmart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980836,"owners_count":21027808,"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":["javascript","javascript-template-engine","jsmart","smarty","smarty-template-engine","template-engine"],"created_at":"2024-08-04T09:01:45.128Z","updated_at":"2025-04-09T05:07:08.558Z","avatar_url":"https://github.com/umakantp.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"jSmart - Smarty template engine in JavaScript\n======\n[![Build Status](https://travis-ci.org/umakantp/jsmart.png?branch=master)](https://travis-ci.org/umakantp/jsmart)\n[![npm version](https://img.shields.io/npm/v/jsmart.svg)](https://www.npmjs.com/package/jsmart)\n[![David](https://img.shields.io/david/dev/umakantp/jsmart.svg)](https://www.npmjs.com/package/jsmart)\n[![npm](https://img.shields.io/npm/dw/jsmart.svg)](https://www.npmjs.com/package/jsmart)\n[![npm](https://img.shields.io/npm/l/jsmart.svg)](https://github.com/umakantp/jsmart/blob/master/LICENSE)\n\njSmart is a port of the Smarty Template Engine to Javascript, a JavaScript template library that supports the template [syntax](https://github.com/umakantp/jsmart/wiki/syntax) and all the features (functions, variable modifiers, etc.) of the well-known PHP template engine [Smarty](http://www.smarty.net/).\n\njSmart is written entirely in JavaScript, does not have any DOM/browser or third-party JavaScript library dependencies and can be run in a web browser as well as a standalone JavaScript interpreter or [CommonJS](http://www.commonjs.org/) environments like [node.js](https://nodejs.org/).\n\njSmart supports plugin architecture, you can [extend it with custom plugins](https://github.com/umakantp/jsmart/wiki/Create-Plugin): functions, blocks and variable modifiers, [templates inclusion](https://github.com/umakantp/jsmart/wiki/Include-Templates), [templates inheritance](https://github.com/umakantp/jsmart/wiki/Template-Inheritance) and overriding, [caching](https://github.com/umakantp/jsmart/wiki/Caching), [escape HTML](https://github.com/umakantp/jsmart/wiki/escape_html).\n\njSmart has some limited support of the [PHP Smarty syntax](https://github.com/umakantp/jsmart/wiki/syntax) and allows you to [use the same Smarty templates on both server and client side](https://github.com/umakantp/jsmart/wiki/Smarty-template-in-javascript), for both PHP and Javascript.\n\nPlay with JsFiddle [demo page](https://jsfiddle.net/8p8xua0k/1/)\n\n### Using jSmart with CDN\n##### Always latest version (don't use in production)\n```\nhttps://cdn.jsdelivr.net/npm/jsmart/dist/jsmart.min.js\n```\n##### Current latest version (4.0.0)\n```\nhttps://cdn.jsdelivr.net/npm/jsmart@3.1.0/dist/jsmart.min.js\n```\n### jSmart with other tools\n\n1. Webpack:- [https://www.npmjs.com/package/jsmart-loader](https://www.npmjs.com/package/jsmart-loader)\n2. Grunt:- [https://www.npmjs.com/package/grunt-jsmart](https://www.npmjs.com/package/grunt-jsmart)\n3. Express Js :- [https://www.npmjs.com/package/jsmart-express](https://www.npmjs.com/package/jsmart-express)\n\n### How to use jSmart in Node.js\n\n1. Install jSmart from NPM Registry\n```\n$ npm install jsmart --save\n```\n\n2. Create template, use [PHP Smarty syntax](https://github.com/umakantp/jsmart/wiki/syntax).  Say demo.tpl\n\n```smarty\nHello {$name}\n```\n\n3. Now lets read the template and compile it. _jSmart_ object compiles the template. You can call _fetch_ function as many times with different data you would want to assign to template.\n```js\nvar fs = require('fs'),\n  jSmart = require('jsmart'),\n  tpl = fs.readFileSync('./demo.tpl', {encoding: 'utf-8'}),\n  compiledTemplate = new jSmart(tpl),\n  output = compiledTemplate.fetch({name: 'World'});\n  // output will be \"Hello world\"\n\nconsole.log(output);\n```\n\n4. Execute the file.\n\n```cli\n$ node demo.js\n```\n\n### How to use jSmart in browser\n\n1. Include jSmart library Javascript file in your header.\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript language=\"javascript\" src=\"jsmart.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n```\n\n2. Create template, use [PHP Smarty syntax](https://github.com/umakantp/jsmart/wiki/syntax). Put the template's text in _\u0026lt;script\u0026gt;_ with the _type=\"text/x-jsmart-tmpl\"_ so a browser will not try to parse it and mess it up.\n```js\n  \u003cscript id=\"test_tpl\" type=\"text/x-jsmart-tmpl\"\u003e\n    Hello {$name}\n  \u003c/script\u003e\n```\n\n3. Create new object of _jSmart_ class, passing the template's text as it's constructor's argument than call _fetch(data)_, where data is an JavaScript object with variables to assign to the template\n```js\n\u003cscript\u003e\n  var content = document.getElementById('test_tpl').innerHTML;\n  var compiled = new jSmart(content);\n  var output = compiled.fetch({name: 'world'});\n  // output will be \"Hello world\"\n\u003c/script\u003e\n```\n\n### How to use jSmart using Require.js\n\n1. If you have configured and installed Require.js it easy to load jSmart and use it. Load jSmart.js file in the browser/environment and it already makes use require js to define module, you got to just include it.\n```js\ndefine(['jSmart'], function (jSmart) {\n  var tplText = 'Hello {$name}';\n  var compiled = new jSmart(tplText);\n  var output = compiled.fetch({name: 'world'});\n  // output is \"Hello world\"\n});\n```\n\n2. You can also make use Require.js text plugin to load templates.\n```js\ndefine(['jSmart', 'text!some/good/template.tpl'], function (jSmart, goodTpl) {\n  var compiled = new jSmart(goodTpl);\n  var output = compiled.fetch({name: 'world'});\n  // output is \"Hello world\"\n});\n```\n\n### DOCUMENTATION\n\n[https://github.com/umakantp/jsmart/wiki](https://github.com/umakantp/jsmart/wiki)\n\n### CONTRIBUTIONS \u0026 TESTS\n\n* Pull request\n  Best is open a issue first. Then send a pull request referencing the issue number. Before sending pull request make sure you add test case for the fix. Make sure all test cases are passing and eslint tests pass.\n\n* Test cases:-\n  ```grunt karma```\n\n* ES Lint tests:-\n  ```grunt eslint```\n\n* Run lint, run test, build, compress, distribution package and update examples in one command:-\n  ```grunt```\n\n### LICENSE\n\n[MIT](https://raw.githubusercontent.com/umakantp/jsmart/master/LICENSE)\n\n### NOTICE\n\nProject originally was created by [miroshnikov](https://github.com/miroshnikov). Since author was not active on project very frequently. I have forked and planned on pushing further improvements and features on my own fork.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumakantp%2Fjsmart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumakantp%2Fjsmart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumakantp%2Fjsmart/lists"}