AJST : Asynchronous JavaScript Template
Introduce
AJST is a JavaScript template engine based on Promise A+.
Template files and data are called asynchronously at the required time to generate Output.
Features
- The syntax is similar to PHP. <? ... ?>
- It uses pure JavaScript without a dedicated template syntax or API.
- If necessary, the template is automatically loaded.
- In the template file you may refer to a different template. Output is returned when all the necessary templates are ready.
- It uses ES6 Promise
Install
npm install ajst --save
Use ES-Module (like TypeScript)
; // module AJST;
Use AMD (like RequireJS)
requirejs;
How to use
tpl/hello.html
Hello, <?include('tpl/world.html', {name: 'John Smith'})?>
tpl/world.html
world! <?=data.name?>
index.js
AJST
Demo
@see AJST Introduce & Test with Bootstrap 3
Browser Compatibility
- IE9+ (IE9 requires es6-shim)
- Google Chrome
- Safari
- FireFox
- Opera
Inspired by...
- John Resig : JavaScript Micro-Templating
- blueimp : JavaScript-Templates
License
(The MIT License)
Copyright (c) 2013 Bum-seok Hwang bitofsky@naver.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.