jsmart3.1.0 • Public • Published
Play with JsFiddle demo page
Using jSmart with CDN
Always latest version (don't use in production)
Current latest version (3.1.0)
jSmart with other tools
- Webpack:- https://www.npmjs.com/package/jsmart-loader
- Grunt:- https://www.npmjs.com/package/grunt-jsmart
- Express Js :- https://www.npmjs.com/package/jsmart-express
How to use jSmart in Node.js
- Install jSmart from NPM Registry
$ npm install jsmart --save
- Create template, use PHP Smarty syntax. Say demo.tpl
- 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.
var fs =jSmart =tpl = fscompiledTemplate = tploutput = compiledTemplate;// output will be "Hello world"console;
- Execute the file.
$ node demo.js
How to use jSmart in browser
- Create template, use PHP Smarty syntax. Put the template's text in <script> with the type="text/x-jsmart-tmpl" so a browser will not try to parse it and mess it up.
<script id="test_tpl" type="text/x-jsmart-tmpl">Hello $name</script>
<script>var content = documentinnerHTML;var compiled = content;var output = compiled;// output will be "Hello world"</script>
How to use jSmart using Require.js
- 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.
- You can also make use Require.js text plugin to load templates.
CONTRIBUTIONS & TESTS
Pull request 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.
ES Lint tests:-
Run lint, run test, build, compress, distribution package and update examples in one command:-
Project originally was created by 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.