| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 three handlers: | 9 * It currently supports three handlers: |
| 10 * | 10 * |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 /** | 46 /** |
| 47 * This handler adds options to a <select> element. | 47 * This handler adds options to a <select> element. |
| 48 * @param {HTMLElement} select The node to modify. | 48 * @param {HTMLElement} select The node to modify. |
| 49 * @param {string} key The name of the value in the dictionary. It should | 49 * @param {string} key The name of the value in the dictionary. It should |
| 50 * identify an array of values to initialize an <option>. Each value, | 50 * identify an array of values to initialize an <option>. Each value, |
| 51 * if a pair, represents [content, value]. Otherwise, it should be a | 51 * if a pair, represents [content, value]. Otherwise, it should be a |
| 52 * content string with no value. | 52 * content string with no value. |
| 53 * @param {LoadTimeData} dictionary The dictionary of strings to draw from. | 53 * @param {LoadTimeData} dictionary The dictionary of strings to draw from. |
| 54 */ | 54 */ |
| 55 'i18n-options': function(select, key, dictionary) { | 55 'i18n-options': function(select, key, dictionary) { |
| 56 var options = dictionary.getString(key); | 56 var options = dictionary.getValue(key); |
| 57 options.forEach(function(optionData) { | 57 options.forEach(function(optionData) { |
| 58 var option = typeof optionData == 'string' ? | 58 var option = typeof optionData == 'string' ? |
| 59 new Option(optionData) : | 59 new Option(optionData) : |
| 60 new Option(optionData[1], optionData[0]); | 60 new Option(optionData[1], optionData[0]); |
| 61 select.appendChild(option); | 61 select.appendChild(option); |
| 62 }); | 62 }); |
| 63 }, | 63 }, |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * This is used to set HTML attributes and DOM properties. The syntax is: | 66 * This is used to set HTML attributes and DOM properties. The syntax is: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (attribute != null) | 127 if (attribute != null) |
| 128 handlers[name](element, attribute, dictionary); | 128 handlers[name](element, attribute, dictionary); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 return { | 133 return { |
| 134 process: process | 134 process: process |
| 135 }; | 135 }; |
| 136 }()); | 136 }()); |
| OLD | NEW |