Skip to content

ajaxRoute.js is a pure-javascript micro-templating library with controller capablities on template html files obtained with an ajax request

License

Notifications You must be signed in to change notification settings

lorepozo/ajaxRoute.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ajaxRoute.js

ajaxRoute.js is a pure-javascript micro-templating library based on ajax requests for template html files that can have embedded moustache javascript.

It is designed to improve user experience and page load times. Content is loaded only when requested, and the user is never actually leaving the page when an ajaxRoute is performed.

See the test example to learn more! You can take a look at my website as well, which uses a slightly modified version of ajaxRoute.

Usage

Simply call the function ajaxRoute on an object described below.

ajaxRoute({
	hash: '/',
	url: 'template.html',
	destination: '#view'
})

Object Argument

  • hash: String hash location e.g. '/' for 'test.html#/'
  • url: String path to file
  • destination: String CSS selector for where parsed content will be placed
  • controller: Object optional contents are referenced in moustache embedded javascript
  • callback: Function(Controller) optional runs after parsed content is placed
  • removeActive: String optional CSS selector to remove .active class from on route
  • bindActive: String optional Attribute name for which .active class will be added on route

bindActive and removeActive

These two parameters are very useful for cases such as

<footer index about contact>
	...
</footer>

Here, you could have the footer only show when on the hashes with the corresponding bindActive values. This would be implemented with removeActive:'' on all ajaxRoutes, and bindActive set to the HTML attributes used (e.g. index, about, contact).

About

ajaxRoute.js is a pure-javascript micro-templating library with controller capablities on template html files obtained with an ajax request

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published