Created
March 28, 2014 16:49
-
-
Save barneycarroll/9837437 to your computer and use it in GitHub Desktop.
A recursive version of csi.js [https://github.com/LexmarkWeb/csi.js] using jQuery. Allows nested templates!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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