Skip to content

Commit

Permalink
Moved some private helper functions out of inner function scopes, for
Browse files Browse the repository at this point in the history
memory optimization.

Added support for white space after target in tmpl tag, e.g. ${ foo } or
${ foo(x) }

Added support for targets that include '.'s and calls to functions, e.g.
${foo.toLowerCase()}

Added support for implicit passing of $data to nested tmpl when no
parameters, so that {{tmpl "#myTmpl"}} is equivalent to
{{tmpl() "#myTmpl"}}, to {{tmpl(null) "#myTmpl"}}, and to
{{tmpl($data) "#myTmpl"}}, and so allows myTmpl to bind to the same data
as the parent template.
(But {{tmpl(foo) "#myTmpl"}} or {{tmpl({}) "#myTmpl"}} will replace the
inherited $data value.)

Added support for inserting a template without data, using
$( "#tmpl" ).tmpl(null).appendTo( "#container" ); - which is equivalent to
$( "#tmpl" ).tmpl( {} ).appendTo( "#container" );
  • Loading branch information
BorisMoore committed Jul 11, 2010
1 parent 8fc69f4 commit a702bbf
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 126 deletions.
2 changes: 1 addition & 1 deletion demos/movies/PagesTmplPlus/movies1.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h1>Netflix: Book a Movie...</h1>
</script>

<script id="bookingEditTmpl" type="text/html">
{{tmpl(this.data, {mode: "Edit"}) "#bookingTitleTmpl"}}
{{tmpl($data, {mode: "Edit"}) "#bookingTitleTmpl"}}
<tr class="bookingEdit">
<td colspan="4">
<div class="fields">
Expand Down
2 changes: 1 addition & 1 deletion demos/movies/PagesTmplPlus/movies2.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>Netflix: Book a Movie...</h1>
</script>

<script id="bookingEditTmpl" type="text/html">
{{tmpl(this.data, {mode: "Edit"}) "#bookingTitleTmpl"}}
{{tmpl($data, {mode: "Edit"}) "#bookingTitleTmpl"}}
<tr class="bookingEdit">
<td colspan="4">
<div class="fields">
Expand Down
2 changes: 1 addition & 1 deletion demos/movies/PagesTmplPlus/movies3.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>Netflix: Book a Movie...</h1>
</script>

<script id="bookingEditTmpl" type="text/html">
{{tmpl(this.data, {mode: "Edit"}) "#bookingTitleTmpl"}}
{{tmpl($data, {mode: "Edit"}) "#bookingTitleTmpl"}}
<tr class="bookingEdit">
<td colspan="4">
<div class="fields">
Expand Down
2 changes: 1 addition & 1 deletion demos/samplesCore/parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
{{if getCityCount(startIndex, endIndex)}}
<tr class="${alternate}"><td colspan="3"><i>Favorite Cities</i></td></tr>
{{each getCities(startIndex, endIndex)}}
{{tmpl({}, {type:"city"}) "#tmplSeparator"}}
{{tmpl(null, {type:"city"}) "#tmplSeparator"}}
<tr class="${alternate}">
<td>${$index + 1}</td>
<td><b>${name}</b></td>
Expand Down
2 changes: 1 addition & 1 deletion demos/samplesTmplPlus/composition.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

<script id="tmplPeople" type="text/html">
{{tmpl "#tmplSeparator"}}
<tr class="${alternate(this.data, people)}"><td colspan="2"><a href="${url}">${getName}</a></td></tr>
<tr class="${alternate($data, people)}"><td colspan="2"><a href="${url}">${getName}</a></td></tr>
{{if cities}}
{{tmpl(cities) getTemplate("City")}}
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion demos/samplesTmplPlus/parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
{{if getCityCount(startIndex, endIndex)}}
<tr class="${alternate}"><td colspan="3"><i>Favorite Cities</i></td></tr>
{{each getCities(startIndex, endIndex)}}
{{tmpl({}, {type:"city"}) "#tmplSeparator"}}
{{tmpl(null, {type:"city"}) "#tmplSeparator"}}
<tr class="${alternate}">
<td>${$index + 1}</td>
<td><b>${name}</b></td>
Expand Down
Loading

0 comments on commit a702bbf

Please sign in to comment.