Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I would like to (programmatically) highlight the dynamic values (context variables) of a thymeleaf template, by say wrapping each one of them in a span and applying a yellow background.
For example, this thymeleaf:

<div th:if="${a} == 'a'" th:text="'hello ' + ${a}?${b}:${c}">

executed with context:

{
  a: 'a',
  b: 'b',
  c: 'c',
}

should output:

<div>hello <span style="background-color: yellow;">b</span></div>

The surrounding span with the background is what I would like to have automatically inserted around every printed variable.

Changing the values themselves (to add the wrapping span) doesn't work because the values can be used in conditionals within the template, so changing values can alter what those conditionals evaluate to.

Search and replace can yield false postives because dynamic values can also organically occur in the template.

How can I achieve this?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.