mirror of
https://github.com/apache/struts.git
synced 2026-08-06 23:27:07 +00:00
WW-5129 Simplifies excluding ignored keys with ?filter
This commit is contained in:
@@ -18,27 +18,22 @@
|
||||
* under the License.
|
||||
*/
|
||||
-->
|
||||
<#function acceptKey(key)>
|
||||
<#if dynamic_attributes_ignore??>
|
||||
<#return !key?starts_with(dynamic_attributes_ignore) >
|
||||
<#else>
|
||||
<#return true>
|
||||
</#if>
|
||||
</#function>
|
||||
<#if (parameters.dynamicAttributes?? && parameters.dynamicAttributes?size > 0)><#rt/>
|
||||
<#assign aKeys = parameters.dynamicAttributes.keySet()><#rt/>
|
||||
<#list aKeys as aKey><#rt/>
|
||||
<#if dynamic_attributes_ignore??>
|
||||
<#if !aKey?starts_with(dynamic_attributes_ignore)>
|
||||
<#list aKeys?filter(acceptKey) as aKey><#rt/>
|
||||
<#assign keyValue = parameters.dynamicAttributes.get(aKey)/>
|
||||
<#if keyValue?is_string>
|
||||
<#assign value = struts.translateVariables(keyValue)!keyValue/>
|
||||
<#assign value = struts.translateVariables(keyValue)!keyValue/>
|
||||
<#else>
|
||||
<#assign value = keyValue?string/>
|
||||
<#assign value = keyValue?string/>
|
||||
</#if>
|
||||
${aKey}="${value}"<#rt/>
|
||||
</#if>
|
||||
<#else>
|
||||
<#assign keyValue = parameters.dynamicAttributes.get(aKey)/>
|
||||
<#if keyValue?is_string>
|
||||
<#assign value = struts.translateVariables(keyValue)!keyValue/>
|
||||
<#else>
|
||||
<#assign value = keyValue?string/>
|
||||
</#if>
|
||||
${aKey}="${value}"<#rt/>
|
||||
</#if>
|
||||
</#list><#rt/>
|
||||
</#if><#rt/>
|
||||
|
||||
+2
-11
@@ -113,12 +113,7 @@ public class FreemarkerResultMockedTest extends StrutsInternalTestCase {
|
||||
ActionMapping mapping = container.getInstance(ActionMapper.class).getMapping(request, configurationManager);
|
||||
dispatcher.serviceAction(request, response, mapping);
|
||||
|
||||
String expectedJDK17 =
|
||||
"<input type=\"text\" name=\"test\" value=\"\" id=\"test\" placeholder=\"input\" foo=\"bar\"/>"
|
||||
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" placeholder=\"input\" foo=\"bar\"/>"
|
||||
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" break=\"true\"/>"
|
||||
+ "<input type=\"text\" name=\"required\" value=\"\" id=\"required\" required=\"true\"/>";
|
||||
String expectedJDK18 =
|
||||
String expected =
|
||||
"<input type=\"text\" name=\"test\" value=\"\" id=\"test\" foo=\"bar\" placeholder=\"input\"/>"
|
||||
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" foo=\"bar\" placeholder=\"input\"/>"
|
||||
+ "<input type=\"text\" name=\"test\" value=\"\" id=\"test\" break=\"true\"/>"
|
||||
@@ -126,11 +121,7 @@ public class FreemarkerResultMockedTest extends StrutsInternalTestCase {
|
||||
|
||||
String result = stringWriter.toString();
|
||||
|
||||
if (result.contains("id=\"test\" foo=\"bar\"")) {
|
||||
assertEquals(expectedJDK18, result);
|
||||
} else {
|
||||
assertEquals(expectedJDK17, result);
|
||||
}
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
public void testManualListInTemplate() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user