Skip to content

minhlucvan/tiny-tpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-template

supper light weight 1kb template engine for jquery

browsers compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
Vivaldi
Vivaldi
IE9, IE10, IE11, Edge all veisions all versions all versions all versions all versions

Features

  • light weight
  • cross browsers
  • mobile friendly
  • array rendering
  • primitive value
  • child template
  • string template
  • dom template
  • animation support
  • pined elements

Usages

Basic

	<div id="tiny-ctn" data-template="#tiny-tpl"></div>
	<script type="text/template" id="tiny-tpl">
		<h1>Hello {% name %}</h1>
	</script>
	$('#tiny-ctn').tinyTpl({name: "Tiny-tpl"});

Very easy, right?

Advanced

I added some animations fade, expand, you can use it individualy or mix together. If you like to add custom one you can write it to prescript and postscript functions.

	<ul id="tiny-ctn" data-template="#tiny-tpl"></ul>
	<script type="text/template" id="tiny-tpl">
		<li>Item {% value %}</li>
	</script>
	// you also can render primitive value as string or number by put {% value %}

	var toggle = 0;
	var data = ["one", "two"];

	$(document).click(function(){
		$("#tiny-ctn").tinyTpl(data[toggle], {animate: "fade|expand"})				
				
		toggle = 1 - toggle;	
	});
	

Array Rendering

Tiny-tpl support array rendering, you simply pass your array as usual, tiny-tpl will render your data one by one.

Pined elements

Pined elements will not be remove when call render, you simply add class tiny-pined to elements that you want to keep.

Contrbutions

All contributions are welcome. If you interst in this project, fork it make it your's and create a pull request.

please keep this eengine as light weight as possible, please don't add no need features.

Issues

If you have any question please ask me here, I will try to answer all.

License

  • 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.

About

supper light weight 1kb template engine for jquery

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published