Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A recursive version of csi.js [https://github.com/LexmarkWeb/csi.js] using jQuery. Allows nested templates!
jQuery.csi = function csi( context ){
$( '[data-include]', context || document ).each( function fetchPartial(){
var $placeholder = $( this );
var location = $placeholder.attr( 'data-include' );
$.ajax( { url : location, async : false } ).done( function injectPartial( response ){
var $partial = $( response );
csi( $partial );
$placeholder.replaceWith( $partial );
} );
} );
};
$( jQuery.csi )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.