rspec/rules/S1926/html/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

62 lines
1.4 KiB
Plaintext

== Why is this an issue?
Web applications can be made available in multiple languages through the use of internationalization. This allows the server to plug in the correct version of a piece of text based on the language chosen, but it requires that internationalization messages be used instead of hard-coded text.
=== Noncompliant code example
[source,html]
----
<form method="post">
<label for="username">Username:</label> <!-- Noncompliant -->
<input type="text" id="username" name="username">
<br>
<label for="password">Password:</label> <!-- Noncompliant -->
<input type="password" id="password" name="password">
<br>
<input type="submit" name="submit" value="${buttonValue}">
</form>
----
=== Compliant solution
[source,html]
----
<form method="post">
<label for="username"><fmt:message key="login.label.username" />:</label>
<input type="text" id="username" name="username">
<br>
<label for="password"><fmt:message key="login.label.password" />:</label>
<input type="password" id="password" name="password">
<br>
<input type="submit" name="submit" value="${buttonValue}">
</form>
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Define this label in the resource bundle.
=== Parameters
.attributes
****
----
outputLabel.value, outputText.value
----
Attributes
****
endif::env-github,rspecator-view[]