Skip to content
This repository
Browse code

Fixes for issues 87 (rendering null as "") and JsViews issue 48 - use…

… of link=false
  • Loading branch information...
commit 5f7636df8a325205888ab41179fbddc7cb0d94ab 1 parent 2eb692a
Boris Moore authored March 20, 2012
15  demos/step-by-step/11_default-values-scenario.html
@@ -13,11 +13,12 @@
13 13
 <body>
14 14
 <a href="index.html">Home</a><br />
15 15
 
16  
-<!---------------------- First Example ---------------------->
17  
-
18 16
 <h3>Example Scenario: providing default values for data.</h3>
19 17
 
  18
+<!---------------------- First Example ---------------------->
  19
+
20 20
 <div class="subhead">The simplest (and best) way: Javascript expression '||':</div>
  21
+
21 22
 <pre>
22 23
 {{:languages||'Languages unavailable'}}
23 24
 </pre>
@@ -29,6 +30,7 @@
29 30
 <!---------------------- Second Example ---------------------->
30 31
 
31 32
 <div class="subhead">Creating a special custom tag:</div>
  33
+
32 34
 <pre>
33 35
 {{get languages defaultValue="No languages!"/}}
34 36
 
@@ -39,9 +41,14 @@
39 41
 });
40 42
 </pre>
41 43
 
  44
+<table><tr class="header"><th>Title</th><th>{{get path default="..."}}</th></tr></tbody>
  45
+	<tbody id="movieList2"></tbody>
  46
+</table>
  47
+
42 48
 <!---------------------- Third Example ---------------------->
43 49
 
44 50
 <div class="subhead">Creating a multi-purpose utility tag:</div>
  51
+
45 52
 <pre>
46 53
 {{yesNo languages yes="Alternate languages available:" no="No alternate languages"/}}
47 54
 
@@ -60,10 +67,6 @@
60 67
 
61 68
 <!------------------ Templates ------------------>
62 69
 
63  
-<table><tr class="header"><th>Title</th><th>{{get path default="..."}}</th></tr></tbody>
64  
-	<tbody id="movieList2"></tbody>
65  
-</table>
66  
-
67 70
 <script id="movieTemplate1" type="text/x-jsrender">
68 71
 	<tr>
69 72
 		<td>{{:title}}</td>
15  jsrender.js
@@ -6,7 +6,7 @@
6 6
  * Copyright 2012, Boris Moore
7 7
  * Released under the MIT License.
8 8
  */
9  
-// informal pre beta commit counter: 1
  9
+// informal pre beta commit counter: 2
10 10
 
11 11
 this.jsviews || this.jQuery && jQuery.views || (function( window, undefined ) {
12 12
 
@@ -158,7 +158,7 @@ function renderTag( tag, parentView, converter, content, tagObject ) {
158 158
 	}
159 159
 
160 160
 	ret = tagFn.apply( tagObject, args.length > 5 ? slice.call( args, 5 ) : [] );
161  
-	return ret || ( ret === undefined ? "" : ret.toString()); // (If ret is the value 0 or false or null, will render to string)
  161
+	return ret || ( ret == undefined ? "" : ret.toString()); // (If ret is the value 0 or false, will render to string)
162 162
 }
163 163
 
164 164
 //=================
@@ -314,9 +314,10 @@ function renderContent( data, context, parentView, path, index ) {
314 314
 			// if no parentContext, use context, or default to {}
315 315
 			: context || {});
316 316
 
317  
-	if ( props.link !== undefined ) {
318  
-		// Override inherited value of link by an explicit setting in props: link=true or link=false
319  
-		context.link = props.link;
  317
+	if ( props.link === FALSE ) {
  318
+		// Override inherited value of link by an explicit setting in props: link=false
  319
+		// The child views of an unlinked view are also unlinked. So setting child back to true will not have any effect.
  320
+		context.link = FALSE;
320 321
 	}
321 322
 	if ( !tmpl.fn ) {
322 323
 		tmpl = templates[ tmpl ] || templates( tmpl );
@@ -489,7 +490,7 @@ function tmplFn( markup, tmpl, bind ) {
489 490
 					? (hasEncoder = TRUE, "e(" + params)
490 491
 					: converter
491 492
 						? (hasConverter = TRUE, 'c("' + converter + '",view,' + params)
492  
-						: (getsValue = TRUE, "((v=" + params + ')!==u?v:""')
  493
+						: (getsValue = TRUE, "((v=" + params + ')!=u?v:""')
493 494
 				)
494 495
 				: (hasTag = TRUE, 't("' + tag + '",view,"' + (converter || "") + '",'
495 496
 					+ (content ? nested.length : '""') // For block tags, pass in the key (nested.length) to the nested content template
@@ -836,7 +837,7 @@ converters({
836 837
 	html: function( text ) {
837 838
 		// HTML encoding helper: Replace < > & and ' and " by corresponding entities.
838 839
 		// inspired by Mike Samuel <msamuel@google.com>
839  
-		return text !== undefined ? String( text ).replace( htmlSpecialChar, replacerForHtml ) : "";
  840
+		return text != undefined ? String( text ).replace( htmlSpecialChar, replacerForHtml ) : "";
840 841
 	}
841 842
 });
842 843
 

0 notes on commit 5f7636d

Please sign in to comment.
Something went wrong with that request. Please try again.