Changeset 9209
- Timestamp:
- 09/08/08 11:00:01 (2 months ago)
- Files:
-
- helma-ng/trunk/apps/demo/skins/continuation.html (modified) (1 diff)
- helma-ng/trunk/apps/storage/skins/index.html (modified) (1 diff)
- helma-ng/trunk/modules/helma/filters.js (modified) (1 diff)
- helma-ng/trunk/modules/helma/skin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
helma-ng/trunk/apps/demo/skins/continuation.html
r9153 r9209 58 58 59 59 <% subskin 'step3' ---------------------------------------------------------------------- %> 60 You said: <h3><% message prefix="»" suffix="«" %></h3>60 You said: <h3><% message | wrap "«" "»" %></h3> 61 61 62 62 <p><a href="http://dev.helma.org/ng/helma.continuation">Learn more about continuations</a> in Helma NG</p> helma-ng/trunk/apps/storage/skins/index.html
r9153 r9209 3 3 <% subskin 'content' %> 4 4 <h1><% title %></h1> 5 <% message prefix="<p>" suffix="</p>" %>5 <% message | prefix "<p>" | suffix "</p>" %> 6 6 7 7 <h3>Add a new book</h3> helma-ng/trunk/modules/helma/filters.js
r8969 r9209 207 207 } 208 208 } 209 210 (function() { 211 var isVisible = function(str) { 212 return str !== undefined && str != null && str != ''; 213 } 214 215 /** 216 * Returns a default string if the given string was empty, undefined 217 * or null. 218 */ 219 this.default_filter = function(input, filter) { 220 return isVisible(input) ? 221 input : 222 filter.getParameter(0); 223 } 224 225 /** 226 * Prepends a prefix if the given string is not empty, undefined or null. 227 */ 228 this.prefix_filter = function(input, filter) { 229 return isVisible(input) ? 230 (filter.getParameter(0) || '') + input : 231 input; 232 } 233 234 /** 235 * Appends a suffix if the given string is not empty, undefined or null. 236 */ 237 this.suffix_filter = function(input, filter) { 238 return isVisible(input) ? 239 input + (filter.getParameter(0) || '') : 240 input; 241 } 242 243 /** 244 * Wraps a non-empty string with a prefix and suffix string. 245 */ 246 this.wrap_filter = function(input, filter) { 247 return isVisible(input) ? 248 (filter.getParameter(0) || '') 249 + input 250 + (filter.getParameter(1) || '') : 251 input; 252 } 253 })(); helma-ng/trunk/modules/helma/skin.js
r9181 r9209 153 153 filter = filter.filter; 154 154 } 155 if (visibleValue || wroteSomething) { 156 res.buffer.insert(length, macro.getParameter('prefix') || ''); 157 if (visibleValue) { 158 res.write(value); 159 } 160 res.write(macro.getParameter('suffix') || ''); 161 } else { 162 res.write(macro.getParameter('default') || ''); 155 if (visibleValue) { 156 res.write(value); 163 157 } 164 158 };