OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This is a simple template engine inspired by JsTemplates | 6 * @fileoverview This is a simple template engine inspired by JsTemplates |
7 * optimized for i18n. | 7 * optimized for i18n. |
8 * | 8 * |
9 * It currently supports two handlers: | 9 * It currently supports two handlers: |
10 * | 10 * |
11 * * i18n-content which sets the textContent of the element | 11 * * i18n-content which sets the textContent of the element |
(...skipping 25 matching lines...) Expand all Loading... | |
37 'i18n-content': function(element, attributeValue, obj) { | 37 'i18n-content': function(element, attributeValue, obj) { |
38 element.textContent = obj[attributeValue]; | 38 element.textContent = obj[attributeValue]; |
39 }, | 39 }, |
40 | 40 |
41 /** | 41 /** |
42 * This handler adds options to a select element. | 42 * This handler adds options to a select element. |
43 */ | 43 */ |
44 'i18n-options': function(element, attributeValue, obj) { | 44 'i18n-options': function(element, attributeValue, obj) { |
45 var options = obj[attributeValue]; | 45 var options = obj[attributeValue]; |
46 options.forEach(function(values) { | 46 options.forEach(function(values) { |
47 var option = typeof values == 'string' ? new Option(values) : | 47 var option; |
48 new Option(values[1], values[0]); | 48 if (typeof values == 'string') { |
49 element.dataType = 'string'; | |
arv (Not doing code reviews)
2011/01/11 21:50:35
This is getting a bit out of hand. Why should i18n
James Hawkins
2011/01/11 23:45:54
I've reverted this change and added handling for a
| |
50 option = new Option(values); | |
51 } else { | |
52 element.dataType = typeof values[0]; | |
53 option = new Option(values[1], values[0]); | |
54 } | |
49 element.appendChild(option); | 55 element.appendChild(option); |
50 }); | 56 }); |
51 }, | 57 }, |
52 | 58 |
53 /** | 59 /** |
54 * This is used to set HTML attributes and DOM properties,. The syntax is: | 60 * This is used to set HTML attributes and DOM properties,. The syntax is: |
55 * attributename:key; | 61 * attributename:key; |
56 * .domProperty:key; | 62 * .domProperty:key; |
57 * .nested.dom.property:key | 63 * .nested.dom.property:key |
58 */ | 64 */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 handlers[name](element, att, obj); | 117 handlers[name](element, att, obj); |
112 } | 118 } |
113 } | 119 } |
114 } | 120 } |
115 } | 121 } |
116 | 122 |
117 return { | 123 return { |
118 process: process | 124 process: process |
119 }; | 125 }; |
120 })(); | 126 })(); |
OLD | NEW |