-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add template resolver for a new location for uswds templates #400
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5bfa581
Add template resolver for a new location for uswds templates
5162f1d
Add docs to readme
8619f57
WIP - Add unit test
79d75fd
Add loaded and unloaded unit tests
91beaaf
Merge branch 'main' into uswds-feature-flag-185770089
spokenbird 8494785
Readme edits
spokenbird File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 15 additions & 11 deletions
26
src/main/java/formflow/library/config/ThymeleafConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions
3
src/main/resources/cfa-uswds-templates/fragments/libraryHead.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<th:block th:fragment="headLinks"> | ||
<!-- CFA USWDS Links --> | ||
</th:block> |
27 changes: 27 additions & 0 deletions
27
src/test/java/formflow/library/config/ThymeleafConfigurationLoadedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package formflow.library.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Objects; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.thymeleaf.TemplateEngine; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@ImportAutoConfiguration(ThymeleafAutoConfiguration.class) | ||
@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=cfa-uswds"}) | ||
public class ThymeleafConfigurationLoadedTest { | ||
|
||
@Autowired | ||
private TemplateEngine templateEngine; | ||
|
||
@Test | ||
void checkThatUSWDSTemplateResolverIsLoaded() { | ||
assertThat(templateEngine.getTemplateResolvers().size()).isEqualTo(2); | ||
var uswdsResolver = templateEngine.getTemplateResolvers().stream() | ||
.filter(x -> Objects.equals(x.getName(), "org.thymeleaf.templateresolver.ClassLoaderTemplateResolver")).findFirst(); | ||
assertThat(uswdsResolver).isPresent(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/formflow/library/config/ThymeleafConfigurationUnloadedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package formflow.library.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Objects; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.thymeleaf.TemplateEngine; | ||
|
||
@ImportAutoConfiguration(ThymeleafAutoConfiguration.class) | ||
@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=honeycrisp"}) | ||
public class ThymeleafConfigurationUnloadedTest { | ||
|
||
@Autowired | ||
private TemplateEngine templateEngine; | ||
|
||
@Test | ||
void checkThatUSWDSTemplateResolverIsLoaded() { | ||
assertThat(templateEngine.getTemplateResolvers().size()).isEqualTo(1); | ||
var uswdsResolver = templateEngine.getTemplateResolvers().stream() | ||
.filter(x -> Objects.equals(x.getName(), "org.thymeleaf.templateresolver.ClassLoaderTemplateResolver")).findFirst(); | ||
assertThat(uswdsResolver).isNotPresent(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might reword this. If I'm correct, it's actually setting the UWDS resolver to be used over the default, meaning that enabling it would turn on the USWDS resolver, but those templates will now replace the same ones from the Honeycrisp resolver? Meaning that turning this on will switch your application to using USWDS styles and components instead of Honeycrisp styles and components.