forked from BorisMoore/jquery-tmpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Second stage of factoring into separate files
- core minimal template functionality in jquery.tmpl.js, intended to enable primary templating scenarios - additional templating features or support for more advanced/less common scenarios in one or more additional files. Currently: jquery.tmplPlus.js. In this commit, jquery.tmplPlus.js contains support for the rendered event, and for the append pattern, which have been removed from jquery.tmpl.js. It also contains the tmplCmd plugin previously in jquery.tmplCmd.js Samples organized into folders based on whether they use only the core tmpl functionality, or additional tmplPlus functionality.
- Loading branch information
1 parent
25dd9f6
commit 8f167dc
Showing
15 changed files
with
175 additions
and
106 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
A jQuery templating plugin - created for demonstration purposes. | ||
____________________________________________________________________ | ||
|
||
// Appends one LI, filled with data, into the UL | ||
$("ul").append( tmpl, dataObject ); | ||
// Render one LI, filled with data, then append it into the UL | ||
$.tmpl( "<li>${firstName}</li>", dataObject ) | ||
.appendTo( "ul" ); | ||
____________________________________________________________________ | ||
|
||
// Appends multiple LI, filled with data, into the UL | ||
$("ul").append( tmpl, arrayOfDataObjects ); | ||
<!-- Declare a template as a script block of type "text/html" --> | ||
<script id="sometmpl" type="text/html"> | ||
<li>${firstName}</li> | ||
</script> | ||
____________________________________________________________________ | ||
|
||
// Render the declared template as one LI appended to the target UL | ||
$( "#sometmpl" ) | ||
.tmpl( dataObject ) | ||
.appendTo( "ul" ); | ||
____________________________________________________________________ | ||
|
||
// Render the declared template as multiple LIs appended to the target UL | ||
// Provide a click event accessing the data | ||
$( "#sometmpl" ) | ||
.tmpl( arrayOfDataObjects ) | ||
.appendTo( "ul" ) | ||
.click( function() { | ||
alert( $.tmpl(this).data.firstName ); | ||
}); | ||
____________________________________________________________________ | ||
|
||
A demo page using this plugin can be found here: | ||
http://infinity88.com/jquery-tmpl/movies/movies.htm |
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
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
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
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
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
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
File renamed without changes.
File renamed without changes.
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
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
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
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
Oops, something went wrong.