/hudson-core/src/main/resources/lib/form/option.jelly

http://github.com/hudson/hudson · Unknown · 43 lines · 38 code · 5 blank · 0 comment · 0 complexity · 4f6e67a2cd54d5371faa7802179b8a7d MD5 · raw file

  1. <!--
  2. The MIT License
  3. Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. -->
  20. <?jelly escape-by-default='true'?>
  21. <j:jelly xmlns:j="jelly:core" xmlns:d="jelly:define" xmlns:st="jelly:stapler">
  22. <st:documentation>
  23. &lt;option> tag for the &lt;select> element that takes true/false for selected.
  24. <st:attribute name="value">
  25. The value to be sent when the form is submitted.
  26. If omitted, the body of the tag will be placed in the value attribute as well
  27. (due to the browser incompatibility between IE and Firefox, value attribute
  28. must be included).
  29. </st:attribute>
  30. <st:attribute name="selected" type="boolean">
  31. If true, the option value appears as selected.
  32. </st:attribute>
  33. </st:documentation>
  34. <!-- No escape/encode to avoid double-encoding if used in value attribute below -->
  35. <j:set var="optionBody" encode="false"><d:invokeBody escapeText="false"/></j:set>
  36. <option value="${attrs.value!=null?attrs.value:h.xmlUnescape(optionBody)}"
  37. selected="${attrs.selected?'true':null}"><j:out value="${optionBody}"/></option>
  38. </j:jelly>