` when the details are expanded.
#### Example
+
```html
+
+```
+
+### MOJ Date picker Element Tag Processor
+
+The `moj:datepicker` custom tag renders a date picker component using the GOV.UK Design System styles and behavior. This
+component is useful for capturing date inputs in a standardized format.
+
+---
+
+### Parameters
+
+| Parameter | Type | Description | Default Value |
+|----------------|--------|--------------------------------------------------------------------------|---------------|
+| `id` | String | The unique ID of the input field. | `"date"` |
+| `name` | String | The name attribute for the input field. | `"date"` |
+| `label` | String | The label text displayed above the date input. | `"Date"` |
+| `hint` | String | Hint text displayed below the label to guide the user. | `""` |
+| `errorMessage` | String | Error message displayed when the input field is invalid. | `""` |
+| `minDate` | String | The minimum date allowed in the date picker (ISO format: `YYYY-MM-DD`). | `""` |
+| `maxDate` | String | The maximum date allowed in the date picker (ISO format: `YYYY-MM-DD`). | `""` |
+| `value` | String | The pre-filled value of the date input field (ISO format: `YYYY-MM-DD`). | `""` |
+
+---
+
+### Usage
+
+Add the `moj:datepicker` tag to your Thymeleaf template with the required parameters:
+
+```html
+
+
+
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/DatePickerAttributes.java b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/DatePickerAttributes.java
new file mode 100644
index 0000000..8451b17
--- /dev/null
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/DatePickerAttributes.java
@@ -0,0 +1,19 @@
+package uk.gov.laa.ccms.springboot.dialect;
+
+/**
+ * DatePickerAttributes.
+ */
+public record DatePickerAttributes(
+ String id,
+ String name,
+ String label,
+ String hint,
+ String errorMessage,
+ String value,
+ String minDate,
+ String maxDate) {
+
+ public boolean hasError() {
+ return errorMessage != null && !errorMessage.isBlank();
+ }
+}
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/DatePickerElementTagProcessor.java b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/DatePickerElementTagProcessor.java
new file mode 100644
index 0000000..9013e15
--- /dev/null
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/DatePickerElementTagProcessor.java
@@ -0,0 +1,110 @@
+package uk.gov.laa.ccms.springboot.dialect;
+
+import static org.springframework.util.StringUtils.hasText;
+
+import java.util.Map;
+import org.thymeleaf.context.ITemplateContext;
+import org.thymeleaf.model.IModel;
+import org.thymeleaf.model.IModelFactory;
+import org.thymeleaf.model.IProcessableElementTag;
+import org.thymeleaf.processor.element.AbstractElementTagProcessor;
+import org.thymeleaf.processor.element.IElementTagStructureHandler;
+import org.thymeleaf.templatemode.TemplateMode;
+
+/**
+ * Transforms
elements into standard HTML button elements.
+ */
+public class DatePickerElementTagProcessor extends AbstractElementTagProcessor {
+
+ private static final String TAG_NAME = "datepicker";
+ private static final int PRECEDENCE = 900;
+
+ public DatePickerElementTagProcessor() {
+ super(TemplateMode.HTML, "moj", TAG_NAME, true, null, false, PRECEDENCE);
+ }
+
+ @Override
+ protected void doProcess(ITemplateContext context, IProcessableElementTag tag,
+ IElementTagStructureHandler structureHandler) {
+
+ Map
attributes = ProcessorUtils.parseAttributes(context, tag);
+ DatePickerAttributes datePickerAttributes = new DatePickerAttributes(
+ attributes.getOrDefault("id", "date"),
+ attributes.getOrDefault("name", "date"),
+ attributes.getOrDefault("label", "Date"),
+ attributes.get("hint"),
+ attributes.get("errorMessage"),
+ attributes.get("value"),
+ attributes.get("minDate"),
+ attributes.get("maxDate")
+ );
+
+ String datePickerHtml = buildDatePickerHtml(datePickerAttributes);
+ final IModelFactory modelFactory = context.getModelFactory();
+ final IModel model = modelFactory.parse(context.getTemplateData(), datePickerHtml);
+ structureHandler.replaceWith(model, false);
+
+ }
+
+ private String buildDatePickerHtml(DatePickerAttributes datePickerAttributes) {
+ StringBuilder html = new StringBuilder();
+ html.append("")
+ .append("
")
+ .append("
");
+
+ return html.toString();
+ }
+}
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/GovUkThymeleafDialectConfig.java b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/GovUkThymeleafDialectConfig.java
index dec055b..edfa956 100644
--- a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/GovUkThymeleafDialectConfig.java
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/GovUkThymeleafDialectConfig.java
@@ -19,4 +19,9 @@ public GovUkDialect govUkDialect() {
return new GovUkDialect();
}
+ @Bean
+ public MojCustomDialect mojCustomDialect() {
+ return new MojCustomDialect();
+ }
+
}
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/MojCustomDialect.java b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/MojCustomDialect.java
new file mode 100644
index 0000000..e139339
--- /dev/null
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/main/java/uk/gov/laa/ccms/springboot/dialect/MojCustomDialect.java
@@ -0,0 +1,21 @@
+package uk.gov.laa.ccms.springboot.dialect;
+
+import java.util.Set;
+import org.thymeleaf.dialect.AbstractProcessorDialect;
+import org.thymeleaf.processor.IProcessor;
+import org.thymeleaf.standard.StandardDialect;
+
+/**
+ * Develops a custom MoJ dialect.
+ */
+public class MojCustomDialect extends AbstractProcessorDialect {
+
+ public MojCustomDialect() {
+ super("MOJ Custom Dialect", "moj", StandardDialect.PROCESSOR_PRECEDENCE);
+ }
+
+ @Override
+ public Set getProcessors(String dialectPrefix) {
+ return Set.of(new DatePickerElementTagProcessor());
+ }
+}
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/MoJDatePickerElementTagProcessorTest.java b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/MoJDatePickerElementTagProcessorTest.java
new file mode 100644
index 0000000..2bf11e5
--- /dev/null
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/MoJDatePickerElementTagProcessorTest.java
@@ -0,0 +1,45 @@
+package uk.gov.laa.ccms.springboot.dialect;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.thymeleaf.context.Context;
+import org.thymeleaf.spring6.SpringTemplateEngine;
+
+@SpringBootTest(classes = ThymeleafTestConfig.class)
+class MoJDatePickerElementTagProcessorTest {
+
+ @Autowired
+ private SpringTemplateEngine templateEngine;
+
+ @Test
+ void shouldRenderGovukButton() {
+
+ Context context = new Context();
+ String renderedHtml = templateEngine.process("test-datepicker", context);
+ assertThat(renderedHtml)
+ .contains(
+ "")
+ .contains(
+ "");
+
+ }
+
+}
\ No newline at end of file
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/ThymeleafTestConfig.java b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/ThymeleafTestConfig.java
index dfe15d3..3f9107d 100644
--- a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/ThymeleafTestConfig.java
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/java/uk/gov/laa/ccms/springboot/dialect/ThymeleafTestConfig.java
@@ -13,6 +13,7 @@ public class ThymeleafTestConfig {
public SpringTemplateEngine testTemplateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addDialect(new GovUkDialect());
+ templateEngine.addDialect(new MojCustomDialect());
templateEngine.addTemplateResolver(templateResolver());
return templateEngine;
}
diff --git a/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/resources/templates/test-datepicker.html b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/resources/templates/test-datepicker.html
new file mode 100644
index 0000000..25c0a63
--- /dev/null
+++ b/laa-ccms-spring-boot-starters/laa-ccms-spring-boot-starter-govuk-dialect/src/test/resources/templates/test-datepicker.html
@@ -0,0 +1,30 @@
+
+
+
+ Datepicker Test
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file